From d4e5882717869aa2facca82f74fe37693fd9e240 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 19 Mar 2025 02:58:09 +0000 Subject: [PATCH 1/9] Update dependencies (2025-03-19 02:58:09) --- packages/autorest.python/package.json | 4 +- packages/typespec-python/package.json | 48 +- pnpm-lock.yaml | 1787 ++++++++++--------------- 3 files changed, 701 insertions(+), 1138 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 6330b8eddcb..8311df3e63e 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "~0.8.0", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} +} \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index a4cc1c8d413..cef3b7f5c61 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -45,37 +45,37 @@ "generator/**" ], "peerDependencies": { - "@typespec/compiler": ">=0.66.0 <1.0.0", - "@typespec/http": ">=0.66.0 <1.0.0", - "@typespec/rest": ">=0.66.0 <1.0.0", - "@typespec/versioning": ">=0.66.0 <1.0.0", - "@typespec/openapi": ">=0.66.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.52.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.52.0 <1.0.0", - "@azure-tools/typespec-autorest": ">=0.52.0 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.52.0 <3.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.52.0 <1.0.0" + "@typespec/compiler": ">=0.67.0 <1.0.0", + "@typespec/http": ">=0.67.0 <1.0.0", + "@typespec/rest": ">=0.67.0 <1.0.0", + "@typespec/versioning": ">=0.67.0 <1.0.0", + "@typespec/openapi": ">=0.67.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.53.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.53.0 <1.0.0", + "@azure-tools/typespec-autorest": ">=0.53.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.53.0 <3.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.53.0 <1.0.0" }, "dependencies": { "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "~0.8.0", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { - "@typespec/compiler": "~0.66.0", - "@typespec/http": "~0.66.0", - "@typespec/rest": "~0.66.0", - "@typespec/versioning": "~0.66.0", - "@typespec/openapi": "~0.66.0", - "@azure-tools/typespec-azure-resource-manager": "~0.52.0", - "@azure-tools/typespec-azure-core": "~0.52.0", - "@azure-tools/typespec-azure-rulesets": "~0.52.0", - "@azure-tools/typespec-autorest": "~0.52.0", - "@azure-tools/typespec-client-generator-core": "~0.52.0", - "@azure-tools/azure-http-specs": "0.1.0-alpha.7", - "@typespec/http-specs": "0.1.0-alpha.11", + "@typespec/compiler": "~0.67.0", + "@typespec/http": "~0.67.0", + "@typespec/rest": "~0.67.0", + "@typespec/versioning": "~0.67.0", + "@typespec/openapi": "~0.67.0", + "@azure-tools/typespec-azure-resource-manager": "~0.53.0", + "@azure-tools/typespec-azure-core": "~0.53.0", + "@azure-tools/typespec-azure-rulesets": "~0.53.0", + "@azure-tools/typespec-autorest": "~0.53.0", + "@azure-tools/typespec-client-generator-core": "~0.53.0", + "@azure-tools/azure-http-specs": "0.1.0-alpha.9", + "@typespec/http-specs": "0.1.0-alpha.13", "@types/js-yaml": "~4.0.5", "@types/node": "~22.5.4", "@types/yargs": "~17.0.33", @@ -89,4 +89,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cdfd347bbcd..3695936eeb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: ~0.8.0 - version: 0.8.0(okmb572npleddk7eu2wecik6ue) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(xyfohv7glp6msr4ipudj2mb5ju) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: ~0.8.0 - version: 0.8.0(phqovtct7xb2vaqtokn2tbhedm) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -95,23 +95,23 @@ importers: version: 4.19.3 devDependencies: '@azure-tools/azure-http-specs': - specifier: 0.1.0-alpha.7 - version: 0.1.0-alpha.7(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@types/node@22.5.5)(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: 0.1.0-alpha.9 + version: 0.1.0-alpha.9(hxmxu44wsiwmqbpvyuomrsmujq) '@azure-tools/typespec-autorest': - specifier: ~0.52.0 - version: 0.52.0(3rl4rvlhrau42sgbqnofgdnzru) + specifier: ~0.53.0 + version: 0.53.0(vsru7ipd7qt42slknz5aanwsou) '@azure-tools/typespec-azure-core': - specifier: ~0.52.0 - version: 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) + specifier: ~0.53.0 + version: 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) '@azure-tools/typespec-azure-resource-manager': - specifier: ~0.52.0 - version: 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: ~0.53.0 + version: 0.53.0(felt6lfzt5orrlwrzxpkykwppa) '@azure-tools/typespec-azure-rulesets': - specifier: ~0.52.0 - version: 0.52.0(hnvyb6ssbaiolad3f2jkopuscy) + specifier: ~0.53.0 + version: 0.53.0(@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))))(@azure-tools/typespec-azure-resource-manager@0.53.0(felt6lfzt5orrlwrzxpkykwppa))(@azure-tools/typespec-client-generator-core@0.53.0(3qm5ewpnxvwkav6ttg6x7temqm))(@typespec/compiler@0.67.1(@types/node@22.5.5)) '@azure-tools/typespec-client-generator-core': - specifier: ~0.52.0 - version: 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: ~0.53.0 + version: 0.53.0(3qm5ewpnxvwkav6ttg6x7temqm) '@types/fs-extra': specifier: 11.0.4 version: 11.0.4 @@ -128,23 +128,23 @@ importers: specifier: ~17.0.33 version: 17.0.33 '@typespec/compiler': - specifier: ~0.66.0 - version: 0.66.0(@types/node@22.5.5) + specifier: ~0.67.0 + version: 0.67.1(@types/node@22.5.5) '@typespec/http': - specifier: ~0.66.0 - version: 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + specifier: ~0.67.0 + version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) '@typespec/http-specs': - specifier: 0.1.0-alpha.11 - version: 0.1.0-alpha.11(@types/node@22.5.5)(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: 0.1.0-alpha.13 + version: 0.1.0-alpha.13(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5))) '@typespec/openapi': - specifier: ~0.66.0 - version: 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: ~0.67.0 + version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) '@typespec/rest': - specifier: ~0.66.0 - version: 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + specifier: ~0.67.0 + version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) '@typespec/versioning': - specifier: ~0.66.0 - version: 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + specifier: ~0.67.0 + version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) c8: specifier: ^10.1.3 version: 10.1.3 @@ -179,69 +179,72 @@ packages: resolution: {integrity: sha512-T21naRb6JDdjjn2s/zwr9iCIv/9jviL/PRtiWAhi+3UA2WKH2wrId2VqJa4uVD7iEV8BLkuGgFmMkaMBG26hFw==} engines: {node: '>=12.0.0'} - '@azure-tools/azure-http-specs@0.1.0-alpha.7': - resolution: {integrity: sha512-5fne+fk4xrSN13VhMrkcOiE30v40IXGIfW6JWCySbZZdQm4wjngWj1YNe+O1Ivy5UIbg6je1Xht1R43kFFOKag==} - engines: {node: '>=18.0.0'} + '@azure-tools/azure-http-specs@0.1.0-alpha.9': + resolution: {integrity: sha512-eygzmoU/MnbhUB54C/fgRX3/98j3we6MYmrLhHSeLtLxVKG3upBxS7gHF0l7jnCE8+jMoaQ1o1WL7xLZuVEifg==} + engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.52.0 - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/rest': ~0.66.0 - '@typespec/versioning': ~0.66.0 - '@typespec/xml': ~0.66.0 - - '@azure-tools/typespec-autorest@0.52.0': - resolution: {integrity: sha512-r08neSPfski9Q3Jvp6tardmS4KXHOML0wSdz5DZgVg0UN+yaVFgLIvMy7VwS636bjpNhwZj8gMT4jYyVM44hlw==} - engines: {node: '>=18.0.0'} + '@azure-tools/typespec-azure-core': ^0.53.0 + '@typespec/compiler': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/rest': ^0.67.0 + '@typespec/versioning': ^0.67.0 + '@typespec/xml': ^0.67.0 + + '@azure-tools/typespec-autorest@0.53.0': + resolution: {integrity: sha512-9eAOTU/so8QOigMcy9YKA43jtMxccSP22wa7Is0ZiX59YTcaUDGlpI+6cFfmGH0tATGCOm5TvjyOkdrhNyKrPw==} + engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.52.0 - '@azure-tools/typespec-azure-resource-manager': ~0.52.0 - '@azure-tools/typespec-client-generator-core': ~0.52.0 - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/openapi': ~0.66.0 - '@typespec/rest': ~0.66.0 - '@typespec/versioning': ~0.66.0 - - '@azure-tools/typespec-azure-core@0.52.0': - resolution: {integrity: sha512-pZkzjQCIgnUdVY0e4YNAAD3vN3HaZim1MMZJRiQaD5vK7WuQQLKYfOf/y8W5zim0GLpvKLNg8mMMmPrRZlW0BQ==} - engines: {node: '>=18.0.0'} + '@azure-tools/typespec-azure-core': ^0.53.0 + '@azure-tools/typespec-azure-resource-manager': ^0.53.0 + '@azure-tools/typespec-client-generator-core': ^0.53.0 + '@typespec/compiler': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/openapi': ^0.67.0 + '@typespec/rest': ^0.67.0 + '@typespec/versioning': ^0.67.0 + + '@azure-tools/typespec-azure-core@0.53.0': + resolution: {integrity: sha512-zG+DV58ApChmkIIoTZ+XMIRsYLm6DnysMofg0o1UEuY50mS71sjzavcwceT8pXekPHtcXkLyYfdd7FyxirCuUA==} + engines: {node: '>=20.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/rest': ~0.66.0 + '@typespec/compiler': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/rest': ^0.67.0 - '@azure-tools/typespec-azure-resource-manager@0.52.0': - resolution: {integrity: sha512-A5nCTEWdAo1tpG5nwWHDMDqEAopp3K3CgbnOB0wwiAV8+zkr5qNC0/48WQvu7pmwlgMDgdvZpNty3bWdLRztQQ==} - engines: {node: '>=18.0.0'} + '@azure-tools/typespec-azure-resource-manager@0.53.0': + resolution: {integrity: sha512-sHeB+HqETYiHoRgcUjr61rxzCn+ITnYrg2gFQ0ExIK/B26hQv50t+VHe1YdrprlqzSvElJD+CtoqQQZffridNw==} + engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.52.0 - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/openapi': ~0.66.0 - '@typespec/rest': ~0.66.0 - '@typespec/versioning': ~0.66.0 - - '@azure-tools/typespec-azure-rulesets@0.52.0': - resolution: {integrity: sha512-fvp2YffW55wSjDMaBA9H/kfxHN6pvPM3JWgUcD4QuC7lnTrBymJHpWIW19X8BbiVPwz9dKEcyY6iHyU/iOyehw==} - engines: {node: '>=18.0.0'} + '@azure-tools/typespec-azure-core': ^0.53.0 + '@typespec/compiler': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/openapi': ^0.67.0 + '@typespec/rest': ^0.67.0 + '@typespec/versioning': ^0.67.0 + + '@azure-tools/typespec-azure-rulesets@0.53.0': + resolution: {integrity: sha512-TsQeFKNQEG0juFzf0dQt8iikPSXGHNyW9hbDrUNrbnjnFvpxUZlL+1aLyI2hBmhHvJQJpLzHViVgKhXTLLBvIQ==} + engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.52.0 - '@azure-tools/typespec-azure-resource-manager': ~0.52.0 - '@azure-tools/typespec-client-generator-core': ~0.52.0 - '@typespec/compiler': ~0.66.0 - - '@azure-tools/typespec-client-generator-core@0.52.0': - resolution: {integrity: sha512-P1kh4mkqPmZY0JsJAtnTRDjzynI05TybgRTsaEnQtFwnlbfUzu1KtKDF4midQDMT6Ao8JEt/S2Nd4nQ1/qrHyQ==} - engines: {node: '>=18.0.0'} + '@azure-tools/typespec-azure-core': ^0.53.0 + '@azure-tools/typespec-azure-resource-manager': ^0.53.0 + '@azure-tools/typespec-client-generator-core': ^0.53.0 + '@typespec/compiler': ^0.67.0 + + '@azure-tools/typespec-client-generator-core@0.53.0': + resolution: {integrity: sha512-EXdkC76HmAdaH0kzET38pPpG7Phoyvp9AFYsAXnQdhRQssfI+x9nxEADix8GZ2n2P1P50ZysvzWeciqgqUbRVw==} + engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.52.0 - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/openapi': ~0.66.0 - '@typespec/rest': ~0.66.0 - '@typespec/versioning': ~0.66.0 - '@typespec/xml': ~0.66.0 + '@azure-tools/typespec-azure-core': ^0.53.0 + '@typespec/compiler': ^0.67.0 + '@typespec/events': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/openapi': ^0.67.0 + '@typespec/rest': ^0.67.0 + '@typespec/sse': ^0.67.0 + '@typespec/streams': ^0.67.0 + '@typespec/versioning': ^0.67.0 + '@typespec/xml': ^0.67.0 '@azure/abort-controller@2.1.2': resolution: {integrity: sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==} @@ -291,8 +294,8 @@ packages: resolution: {integrity: sha512-D6G7FEmDiTctPKuWegX2WTrS1enKZwqYwdKTO6ZN6JMigcCehlT0/CYl+zWpI9vQ9frwwp7GQT3/owaEXgnOsA==} engines: {node: '>=18.0.0'} - '@azure/identity@4.6.0': - resolution: {integrity: sha512-ANpO1iAvcZmpD4QY7/kaE/P2n66pRXsDp3nMUC6Ow3c9KfXOZF7qMU9VgqPw8m7adP7TVIbVyrCEmD9cth3KQQ==} + '@azure/identity@4.7.0': + resolution: {integrity: sha512-6z/S2KorkbKaZ0DgZFVRdu7RCuATmMSTjKpuhj7YpjxkJ0vnJ7kTM3cpNgzFgk9OPYfZ31wrBEtC/iwAS4jQDA==} engines: {node: '>=18.0.0'} '@azure/logger@1.1.4': @@ -303,16 +306,16 @@ packages: resolution: {integrity: sha512-vcva6qA4ytVjg52Ew+RxXGKRuoDMdvNOwT+kECNC36kujYalFQe9B5SNud4WVa/Zk12KFa0bkOHFnjP8cgDv3A==} engines: {node: '>=0.8.0'} - '@azure/msal-common@14.16.0': - resolution: {integrity: sha512-1KOZj9IpcDSwpNiQNjt0jDYZpQvNZay7QAEi/5DLubay40iGYtLzya/jbjRPLyOTZhEKyL1MzPuw2HqBCjceYA==} - engines: {node: '>=0.8.0'} - '@azure/msal-common@15.2.0': resolution: {integrity: sha512-HiYfGAKthisUYqHG1nImCf/uzcyS31wng3o+CycWLIM9chnYJ9Lk6jZ30Y6YiYYpTQ9+z/FGUpiKKekd3Arc0A==} engines: {node: '>=0.8.0'} - '@azure/msal-node@2.16.2': - resolution: {integrity: sha512-An7l1hEr0w1HMMh1LU+rtDtqL7/jw74ORlc9Wnh06v7TU/xpG39/Zdr1ZJu3QpjUfKJ+E0/OXMW8DRSWTlh7qQ==} + '@azure/msal-common@15.2.1': + resolution: {integrity: sha512-eZHtYE5OHDN0o2NahCENkczQ6ffGc0MoUSAI3hpwGpZBHJXaEQMMZPWtIx86da2L9w7uT+Tr/xgJbGwIkvTZTQ==} + engines: {node: '>=0.8.0'} + + '@azure/msal-node@3.3.0': + resolution: {integrity: sha512-ulsT3EHF1RQ29X55cxBLgKsIKWni9JdbUqG7sipGVP4uhWcBpmm/vhKOMH340+27Acm9+kHGnN/5XmQ5LrIDgA==} engines: {node: '>=16'} '@azure/storage-blob@12.25.0': @@ -1019,9 +1022,6 @@ packages: resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} engines: {node: '>=18.0.0'} - '@isaacs/string-locale-compare@1.1.0': - resolution: {integrity: sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==} - '@istanbuljs/schema@0.1.3': resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -1057,97 +1057,39 @@ packages: resolution: {integrity: sha512-OrcNPXdpSl9UX7qPVRWbmWMCSXrcDa2M9DvrbOTj7ao1S4PlqVFYv9/yLKMkrJKZ/V5A/kDBC690or307i26Og==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/agent@3.0.0': - resolution: {integrity: sha512-S79NdEgDQd/NGCay6TCoVzXSj74skRZIKJcpJjC5lOq34SZzyI6MqtiiWoiVWoVrTcGjNeC4ipbh1VIHlpfF5Q==} - engines: {node: ^18.17.0 || >=20.5.0} - - '@npmcli/arborist@8.0.0': - resolution: {integrity: sha512-APDXxtXGSftyXibl0dZ3CuZYmmVnkiN3+gkqwXshY4GKC2rof2+Lg0sGuj6H1p2YfBAKd7PRwuMVhu6Pf/nQ/A==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - '@npmcli/fs@3.1.1': resolution: {integrity: sha512-q9CRWjpHCMIh5sVyefoD1cA7PkvILqCZsnSOEUUivORLjxCO/Irmue2DprETiNgEqktDBZaM1Bi+jrarx1XdCg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - '@npmcli/fs@4.0.0': - resolution: {integrity: sha512-/xGlezI6xfGO9NwuJlnwz/K14qD1kCSAGtacBHnGzeAIuJGazcp45KP5NuyARXoKb7cwulAGWVsbeSxdG/cb0Q==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/git@5.0.8': resolution: {integrity: sha512-liASfw5cqhjNW9UFd+ruwwdEf/lbOAQjLL2XY2dFW/bkJheXDYZgOyul/4gVvEV4BWkTXjYGmDqMw9uegdbJNQ==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/git@6.0.3': - resolution: {integrity: sha512-GUYESQlxZRAdhs3UhbB6pVRNUELQOHXwK9ruDkwmCv2aZ5y0SApQzUJCg02p3A7Ue2J5hxvlk1YI53c00NmRyQ==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/installed-package-contents@2.1.0': resolution: {integrity: sha512-c8UuGLeZpm69BryRykLuKRyKFZYJsZSCT4aVY5ds4omyZqJ172ApzgfKJ5eV/r3HgLdUYgFVe54KSFVjKoe27w==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} hasBin: true - '@npmcli/installed-package-contents@3.0.0': - resolution: {integrity: sha512-fkxoPuFGvxyrH+OQzyTkX2LUEamrF4jZSmxjAtPPHHGO0dqsQ8tTKjnIS8SAnPHdk2I03BDtSMR5K/4loKg79Q==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - - '@npmcli/map-workspaces@4.0.2': - resolution: {integrity: sha512-mnuMuibEbkaBTYj9HQ3dMe6L0ylYW+s/gfz7tBDMFY/la0w9Kf44P9aLn4/+/t3aTR3YUHKoT6XQL9rlicIe3Q==} - engines: {node: ^18.17.0 || >=20.5.0} - - '@npmcli/metavuln-calculator@8.0.1': - resolution: {integrity: sha512-WXlJx9cz3CfHSt9W9Opi1PTFc4WZLFomm5O8wekxQZmkyljrBRwATwDxfC9iOXJwYVmfiW1C1dUe0W2aN0UrSg==} - engines: {node: ^18.17.0 || >=20.5.0} - - '@npmcli/name-from-folder@3.0.0': - resolution: {integrity: sha512-61cDL8LUc9y80fXn+lir+iVt8IS0xHqEKwPu/5jCjxQTVoSCmkXvw4vbMrzAMtmghz3/AkiBjhHkDKUH+kf7kA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/node-gyp@3.0.0': resolution: {integrity: sha512-gp8pRXC2oOxu0DUE1/M3bYtb1b3/DbJ5aM113+XJBgfXdussRAsX0YOrOhdd8WvnAR6auDBvJomGAkLKA5ydxA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - '@npmcli/node-gyp@4.0.0': - resolution: {integrity: sha512-+t5DZ6mO/QFh78PByMq1fGSAub/agLJZDRfJRMeOSNCt8s9YVlTjmGpIPwPhvXTGUIJk+WszlT0rQa1W33yzNA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/package-json@5.2.1': resolution: {integrity: sha512-f7zYC6kQautXHvNbLEWgD/uGu1+xCn9izgqBfgItWSx22U0ZDekxN08A1vM8cTxj/cRVe0Q94Ode+tdoYmIOOQ==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/package-json@6.1.1': - resolution: {integrity: sha512-d5qimadRAUCO4A/Txw71VM7UrRZzV+NPclxz/dc+M6B2oYwjWTjqh8HA/sGQgs9VZuJ6I/P7XIAlJvgrl27ZOw==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/promise-spawn@7.0.2': resolution: {integrity: sha512-xhfYPXoV5Dy4UkY0D+v2KkwvnDfiA/8Mt3sWCGI/hM03NsYIH8ZaG6QzS9x7pje5vHZBZJ2v6VRFVTWACnqcmQ==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/promise-spawn@8.0.2': - resolution: {integrity: sha512-/bNJhjc+o6qL+Dwz/bqfTQClkEO5nTQ1ZEcdCkAQjhkZMHIh22LPG7fNh1enJP1NKWDqYiiABnjFCY7E0zHYtQ==} - engines: {node: ^18.17.0 || >=20.5.0} - - '@npmcli/query@4.0.0': - resolution: {integrity: sha512-3pPbese0fbCiFJ/7/X1GBgxAKYFE8sxBddA7GtuRmOgNseH4YbGsXJ807Ig3AEwNITjDUISHglvy89cyDJnAwA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/redact@2.0.1': resolution: {integrity: sha512-YgsR5jCQZhVmTJvjduTOIHph0L73pK8xwMVaDY0PatySqVM9AZj93jpoXYSJqfHFxFkN9dmqTw6OiqExsS3LPw==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/redact@3.1.1': - resolution: {integrity: sha512-3Hc2KGIkrvJWJqTbvueXzBeZlmvoOxc2jyX00yzr3+sNFquJg0N8hH4SAPLPVrkWIRQICVpVgjrss971awXVnA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@npmcli/run-script@8.1.0': resolution: {integrity: sha512-y7efHHwghQfk28G2z3tlZ67pLG0XdfYbcVG26r7YIXALRsrVQcTq4/tdenSmdOrEsNahIYA/eh8aEVROWGFUDg==} engines: {node: ^16.14.0 || >=18.0.0} - '@npmcli/run-script@9.0.2': - resolution: {integrity: sha512-cJXiUlycdizQwvqE1iaAb4VRUM3RX09/8q46zjvy+ct9GhfZRWd7jXYVc1tn/CfRlGPVkX/u4sstRlepsm7hfw==} - engines: {node: ^18.17.0 || >=20.5.0} - '@octokit/app@15.1.0': resolution: {integrity: sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg==} engines: {node: '>= 18'} @@ -1398,50 +1340,26 @@ packages: resolution: {integrity: sha512-wueKWDk70QixNLB363yHc2D2ItTgYiMTdPwK8D9dKQMR3ZQ0c35IxP5xnwQ8cNLoCgCRcHf14kE+CLIvNX1zmA==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/bundle@3.1.0': - resolution: {integrity: sha512-Mm1E3/CmDDCz3nDhFKTuYdB47EdRFRQMOE/EAbiG1MJW77/w1b3P7Qx7JSrVJs8PfwOLOVcKQCHErIwCTyPbag==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sigstore/core@1.1.0': resolution: {integrity: sha512-JzBqdVIyqm2FRQCulY6nbQzMpJJpSiJ8XXWMhtOX9eKgaXXpfNOF53lzQEjIydlStnd/eFtuC1dW4VYdD93oRg==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/core@2.0.0': - resolution: {integrity: sha512-nYxaSb/MtlSI+JWcwTHQxyNmWeWrUXJJ/G4liLrGG7+tS4vAz6LF3xRXqLH6wPIVUoZQel2Fs4ddLx4NCpiIYg==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sigstore/protobuf-specs@0.3.2': resolution: {integrity: sha512-c6B0ehIWxMI8wiS/bj6rHMPqeFvngFV7cDU/MY+B16P9Z3Mp9k8L93eYZ7BYzSickzuqAQqAq0V956b3Ju6mLw==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/protobuf-specs@0.4.0': - resolution: {integrity: sha512-o09cLSIq9EKyRXwryWDOJagkml9XgQCoCSRjHOnHLnvsivaW7Qznzz6yjfV7PHJHhIvyp8OH7OX8w0Dc5bQK7A==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sigstore/sign@2.3.2': resolution: {integrity: sha512-5Vz5dPVuunIIvC5vBb0APwo7qKA4G9yM48kPWJT+OEERs40md5GoUR1yedwpekWZ4m0Hhw44m6zU+ObsON+iDA==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/sign@3.1.0': - resolution: {integrity: sha512-knzjmaOHOov1Ur7N/z4B1oPqZ0QX5geUfhrVaqVlu+hl0EAoL4o+l0MSULINcD5GCWe3Z0+YJO8ues6vFlW0Yw==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sigstore/tuf@2.3.4': resolution: {integrity: sha512-44vtsveTPUpqhm9NCrbU8CWLe3Vck2HO1PNLw7RIajbB7xhtn5RBPm1VNSCMwqGYHhDsBJG8gDF0q4lgydsJvw==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/tuf@3.1.0': - resolution: {integrity: sha512-suVMQEA+sKdOz5hwP9qNcEjX6B45R+hFFr4LAWzbRc5O+U2IInwvay/bpG5a4s+qR35P/JK/PiKiRGjfuLy1IA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sigstore/verify@1.2.1': resolution: {integrity: sha512-8iKx79/F73DKbGfRf7+t4dqrc0bRr0thdPrxAtCKWRm/F0tG71i6O1rvlnScncJLLBZHn3h8M3c1BSUAb9yu8g==} engines: {node: ^16.14.0 || >=18.0.0} - '@sigstore/verify@2.1.0': - resolution: {integrity: sha512-kAAM06ca4CzhvjIZdONAL9+MLppW3K48wOFy1TbuaWFW/OMfl8JuTgW0Bm02JB1WJGT/ET2eqav0KTEKmxqkIA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@sindresorhus/merge-streams@2.3.0': resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} @@ -1454,10 +1372,6 @@ packages: resolution: {integrity: sha512-92F7/SFyufn4DXsha9+QfKnN03JGqtMFMXgSHbZOo8JG59WkTni7UzAouNQDf7AuP9OAMxVOPQcqG3sB7w+kkg==} engines: {node: ^16.14.0 || >=18.0.0} - '@tufjs/models@3.0.1': - resolution: {integrity: sha512-UUYHISyhCU3ZgN8yaear3cGATHb3SMuKHsQ/nVbHXcmnBf+LzQ/cQfhNG+rfaSHgqGKNEm2cOCLVLELStUQ1JA==} - engines: {node: ^18.17.0 || >=20.5.0} - '@types/aws-lambda@8.10.145': resolution: {integrity: sha512-dtByW6WiFk5W5Jfgz1VM+YPA21xMXTuSFoLYIDY0L44jDLLflVPtZkYuu3/YxpGcvjzKFBZLU+GyKjR0HOYtyw==} @@ -1485,8 +1399,8 @@ packages: '@types/jsonfile@6.1.4': resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} - '@types/node@22.10.10': - resolution: {integrity: sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==} + '@types/node@22.13.10': + resolution: {integrity: sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==} '@types/node@22.5.5': resolution: {integrity: sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==} @@ -1610,78 +1524,100 @@ packages: resolution: {integrity: sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typespec/compiler@0.66.0': - resolution: {integrity: sha512-JoaHQCc1Va48xuiws7UHFa9ix1bxxJrjTud69mrbu67HerqLN5meLwNkqVGrOlEfUnvMcnaXNQlHbMbixmshQA==} - engines: {node: '>=18.0.0'} + '@typespec/compiler@0.67.1': + resolution: {integrity: sha512-inaJUlbwvFBNiT8ViXZ4O2m0ECiLPkkp0Ek1wNquxpWNHxgvfFDH/JTv5SXXwL5FXY+uym9hNcyjmHQB7RJExw==} + engines: {node: '>=20.0.0'} hasBin: true - '@typespec/http-client-python@0.8.0': - resolution: {integrity: sha512-JjbOyXall3aqdy5QtCDwRcExZ9IOdlwntdzmbR70PdTVLIyg8XqgSwx3B/A57/H7UbBkvvwVEVfVMvpiodlv/A==} + '@typespec/events@0.67.1': + resolution: {integrity: sha512-4pd/FEd+y72h2eUOlwGavK+nv3SDp7ZUJkGTcARyjLH5aSIAOl4uYW+WzQjGJylu/9t+xmoHy47siOvYBxONkQ==} + engines: {node: '>=20.0.0'} + peerDependencies: + '@typespec/compiler': ^0.67.1 + + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz} + version: 0.8.0 engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-autorest': '>=0.52.0 <1.0.0' - '@azure-tools/typespec-azure-core': '>=0.52.0 <1.0.0' - '@azure-tools/typespec-azure-resource-manager': '>=0.52.0 <1.0.0' - '@azure-tools/typespec-azure-rulesets': '>=0.52.0 <3.0.0' - '@azure-tools/typespec-client-generator-core': '>=0.52.0 <1.0.0' - '@typespec/compiler': '>=0.66.0 <1.0.0' - '@typespec/http': '>=0.66.0 <1.0.0' - '@typespec/openapi': '>=0.66.0 <1.0.0' - '@typespec/rest': '>=0.66.0 <1.0.0' - '@typespec/versioning': '>=0.66.0 <1.0.0' - - '@typespec/http-specs@0.1.0-alpha.11': - resolution: {integrity: sha512-VOE84qmxKA5PJtb+xYXuhZT5d/JBuKIN3EQlt1+g256/gl4HuImMl3SEoGtO+gCn7pJ/rkRiVodELNQY6c6fbw==} + '@azure-tools/typespec-autorest': '>=0.53.0 <1.0.0' + '@azure-tools/typespec-azure-core': '>=0.53.0 <1.0.0' + '@azure-tools/typespec-azure-resource-manager': '>=0.53.0 <1.0.0' + '@azure-tools/typespec-azure-rulesets': '>=0.53.0 <3.0.0' + '@azure-tools/typespec-client-generator-core': '>=0.53.0 <1.0.0' + '@typespec/compiler': '>=0.67.0 <1.0.0' + '@typespec/http': '>=0.67.0 <1.0.0' + '@typespec/openapi': '>=0.67.0 <1.0.0' + '@typespec/rest': '>=0.67.0 <1.0.0' + '@typespec/versioning': '>=0.67.0 <1.0.0' + + '@typespec/http-specs@0.1.0-alpha.13': + resolution: {integrity: sha512-QBJNnXWCYShI5PSt89oCvSwFsXV/9kYBXSxWaPHYk0qa6CjUdMEbwZrSbV1BDhcyqbFE3e2LLCjX8dTjWJ6Fuw==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 - '@typespec/rest': ~0.66.0 - '@typespec/versioning': ~0.66.0 - '@typespec/xml': ~0.66.0 - - '@typespec/http@0.66.0': - resolution: {integrity: sha512-IKD5FMvnjbZ5cdQ3wTXXAnnQgDcqFuPtVphpTdnYER87gGEa8YNLocgK44CLFB+GvVkTecDltG0CNKPSPQ0RMw==} - engines: {node: '>=18.0.0'} + '@typespec/compiler': ^0.67.0 + '@typespec/http': ^0.67.0 + '@typespec/rest': ^0.67.0 + '@typespec/versioning': ^0.67.0 + '@typespec/xml': ^0.67.0 + + '@typespec/http@0.67.1': + resolution: {integrity: sha512-pkLFdKLA5ObCptUuwL8mhiy6EqVbqmtvHK89zqiTfYYGw2qm76+EUHaK0P/g2aAmjcwlrDGhJ0EhzbVp87H0mg==} + engines: {node: '>=20.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 - '@typespec/streams': ~0.66.0 + '@typespec/compiler': ^0.67.1 + '@typespec/streams': ^0.67.1 peerDependenciesMeta: '@typespec/streams': optional: true - '@typespec/openapi@0.66.0': - resolution: {integrity: sha512-Oiwx2glN5bET4C3cuU5DIhd7nL/wBi+tg1KGBx0bU4KogLaGf+BLW5ak0Epxnvhy8VYvPhCpTGbez0I6gkEOwA==} - engines: {node: '>=18.0.0'} + '@typespec/openapi@0.67.1': + resolution: {integrity: sha512-9/122dHw6ZA+laqHM1mqa0CWxg0lBhEqdVX74YoAOlE+NR2wIpUwwC4WIVTvIllDIl6hwV+zVgILtbvD8W5+1A==} + engines: {node: '>=20.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 + '@typespec/compiler': ^0.67.1 + '@typespec/http': ^0.67.1 - '@typespec/rest@0.66.0': - resolution: {integrity: sha512-r/o1GXz/BB9lgMPzMkrLIhTUm4elx5JAD/t6QGWDdUptXntVSapCYmIwCV/Iv10+QnHrsB1/v152nz9nd4lOHg==} - engines: {node: '>=18.0.0'} + '@typespec/rest@0.67.1': + resolution: {integrity: sha512-19IzFoaM0yFBSXpfrJgZEBVXtvEkMEprKc5B0kF4ylEPs32ShtZj05BXYrAkmMZbCsk0AC/VZdmVgcWP+AT6GQ==} + engines: {node: '>=20.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 - '@typespec/http': ~0.66.0 + '@typespec/compiler': ^0.67.1 + '@typespec/http': ^0.67.1 - '@typespec/spec-api@0.1.0-alpha.1': - resolution: {integrity: sha512-WjZ3D/Narn264gUIU4bZ1iSLsPeIMUjCX1k91+H93UNCp7TeX/RO5jDG08Ryp9TnZDRITMPcs4TRfO3p0551AA==} - engines: {node: '>=18.0.0'} + '@typespec/spec-api@0.1.0-alpha.3-dev.0': + resolution: {integrity: sha512-zMozvoCEDERYvGMgT2EvuNyIcaFvf3pUXWhc7jyhJK2zI0z2ELnT4gUEynJ3ugI/ICaWtxHrGkwueaf508a5gQ==} + engines: {node: '>=20.0.0'} - '@typespec/spec-coverage-sdk@0.1.0-alpha.3': - resolution: {integrity: sha512-1n6xng80jPkS05S8vkkQ6eHtud4hIxe5VtxrqUjx5LfLPE4azV3CiVf8zbzzsR6c2DFsF7XtfcjVjcUgBHDaMA==} + '@typespec/spec-coverage-sdk@0.1.0-alpha.5-dev.0': + resolution: {integrity: sha512-I0p1ogrB3hW16K9IJyxFUz6AvuQ8NDsiLrav5ujGGJbW3gXdp+N6MzxXp5NNs4jfHoryX4kkA7xlTiPqKz3Pcw==} engines: {node: '>=16.0.0'} - '@typespec/spector@0.1.0-alpha.8': - resolution: {integrity: sha512-rS6OLMFAFpVT8cOs4T9OD2deTC62EEStVCv2bg1Hc/RMzPg7gy1h37Zm6NYcI3HQa7bIy3jdds/VSsZqofzavg==} + '@typespec/spector@0.1.0-alpha.9': + resolution: {integrity: sha512-plD3bZGqk1v2+pJoZl/TNxWlkS7mMzPNPtd+HkKbjmFxQfFUQGPvmkRq4YGijj9gjqcwYXrzQ10L8/emv9ZnoQ==} engines: {node: '>=16.0.0'} hasBin: true - '@typespec/versioning@0.66.0': - resolution: {integrity: sha512-8AhTpo6jxcjwxZPAegI/sDEePoqXz5Si8XBw/x7jz+EkBvbgqT9GT0UUzJL1XgOwQaks2aMr4DdOn8n9kOCltg==} - engines: {node: '>=18.0.0'} + '@typespec/sse@0.67.1': + resolution: {integrity: sha512-Y7O002u89nM55hc81/wadMG0+gnj9hr0i4icqOxjP7auWsYDwMoK7arxC+qM7tyyFGMgv/F0ZxNJmc2Ajq7kpQ==} + engines: {node: '>=20.0.0'} peerDependencies: - '@typespec/compiler': ~0.66.0 + '@typespec/compiler': ^0.67.1 + '@typespec/events': ^0.67.1 + '@typespec/http': ^0.67.1 + '@typespec/streams': ^0.67.1 + + '@typespec/streams@0.67.1': + resolution: {integrity: sha512-it+WNzurrk+TEzLvqlbCreyATmSR/g61/YX/k1D+B/QThPv8bh2S1sQqKtUMeThCu4/MHhZL9xTtdxWcLww+lg==} + engines: {node: '>=20.0.0'} + peerDependencies: + '@typespec/compiler': ^0.67.1 + + '@typespec/versioning@0.67.1': + resolution: {integrity: sha512-i1eZT8JlCthkRHJS3NH/nZTHUD7gJozP6pVy8wyHBx6TbnDOTfQ1P5YVlL2pF4ZdeRbGFhOKiUF/usEIOrkaVw==} + engines: {node: '>=20.0.0'} + peerDependencies: + '@typespec/compiler': ^0.67.1 '@typespec/xml@0.59.0': resolution: {integrity: sha512-UoSsEmm7SXEtL9OXsqotu1TjruJSobqZMhUKAAlC9EP2WfQIHLRfBu7xaZB0sgwq7CM6zy/Hq1RZfQyL1KqEvg==} @@ -1722,10 +1658,6 @@ packages: resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - abbrev@3.0.0: - resolution: {integrity: sha512-+/kfrslGQ7TNV2ecmQwMJj/B65g5KVq1/L3SGVZ3tCYGqlzFuFCGBZJtMP99wH3NpEUyAjn0zPdPUg0D+DwrOA==} - engines: {node: ^18.17.0 || >=20.5.0} - accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -1853,10 +1785,6 @@ packages: before-after-hook@3.0.2: resolution: {integrity: sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==} - bin-links@5.0.0: - resolution: {integrity: sha512-sdleLVfCjBtgO5cNjA2HVRvWBJAHs4zwenaCPMNJAJU0yNxpzj80IpjOIimkpkr+mhlA+how5poQtt53PygbHA==} - engines: {node: ^18.17.0 || >=20.5.0} - body-parser@1.20.3: resolution: {integrity: sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -1889,6 +1817,10 @@ packages: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} + busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -1915,9 +1847,9 @@ packages: resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} engines: {node: ^16.14.0 || >=18.0.0} - cacache@19.0.1: - resolution: {integrity: sha512-hdsUxulXCi5STId78vRVYEtDAjq99ICAUktLTeTYsLoTE6Z8dS0c8pWNCxwdrk9YfJeobDZc2Y186hD/5ZQgFQ==} - engines: {node: ^18.17.0 || >=20.5.0} + call-bind-apply-helpers@1.0.2: + resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} + engines: {node: '>= 0.4'} call-bind@1.0.7: resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} @@ -2000,10 +1932,6 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} - cmd-shim@7.0.0: - resolution: {integrity: sha512-rtpaCbr164TPPh+zFdkWpCyZuKkjpAzODfaZCf/SVJZzJN+4bHQb/LP3Jzq5/+84um3XXY8r548XiWKSborwVw==} - engines: {node: ^18.17.0 || >=20.5.0} - color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -2045,9 +1973,6 @@ packages: resolution: {integrity: sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==} engines: {node: '>= 6'} - common-ancestor-path@1.0.1: - resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} - commonmark@0.30.0: resolution: {integrity: sha512-j1yoUo4gxPND1JWV9xj5ELih0yMv1iCWDG6eEQIPLSWLxzCXiFoyS7kvB+WwU+tZMf4snwJMMtaubV0laFpiBA==} hasBin: true @@ -2152,11 +2077,6 @@ packages: engines: {node: '>=16'} hasBin: true - cssesc@3.0.0: - resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} - engines: {node: '>=4'} - hasBin: true - data-uri-to-buffer@4.0.1: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} engines: {node: '>= 12'} @@ -2218,13 +2138,21 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + default-browser-id@5.0.0: + resolution: {integrity: sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==} + engines: {node: '>=18'} + + default-browser@5.2.1: + resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==} + engines: {node: '>=18'} + define-data-property@1.1.4: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} - define-lazy-prop@2.0.0: - resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} - engines: {node: '>=8'} + define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} define-properties@1.2.1: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} @@ -2253,6 +2181,10 @@ packages: resolution: {integrity: sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==} engines: {node: '>=10'} + dunder-proto@1.0.1: + resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} + engines: {node: '>= 0.4'} + eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -2302,6 +2234,10 @@ packages: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} engines: {node: '>=6'} + env-paths@3.0.0: + resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + err-code@2.0.3: resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==} @@ -2316,6 +2252,10 @@ packages: resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} engines: {node: '>= 0.4'} + es-define-property@1.0.1: + resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} + engines: {node: '>= 0.4'} + es-errors@1.3.0: resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} engines: {node: '>= 0.4'} @@ -2330,10 +2270,18 @@ packages: resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==} engines: {node: '>= 0.4'} + es-object-atoms@1.1.1: + resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} + engines: {node: '>= 0.4'} + es-set-tostringtag@2.0.3: resolution: {integrity: sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==} engines: {node: '>= 0.4'} + es-set-tostringtag@2.1.0: + resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} + engines: {node: '>= 0.4'} + es-shim-unscopables@1.0.2: resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==} @@ -2515,6 +2463,10 @@ packages: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} + fast-glob@3.3.3: + resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} + engines: {node: '>=8.6.0'} + fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -2596,8 +2548,8 @@ packages: resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} engines: {node: '>=14'} - form-data@4.0.1: - resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==} + form-data@4.0.2: + resolution: {integrity: sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==} engines: {node: '>= 6'} formdata-polyfill@4.0.10: @@ -2661,6 +2613,14 @@ packages: resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} engines: {node: '>= 0.4'} + get-intrinsic@1.3.0: + resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} + engines: {node: '>= 0.4'} + + get-proto@1.0.1: + resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} + engines: {node: '>= 0.4'} + get-stdin@9.0.0: resolution: {integrity: sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==} engines: {node: '>=12'} @@ -2718,9 +2678,17 @@ packages: resolution: {integrity: sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==} engines: {node: '>=18'} + globby@14.1.0: + resolution: {integrity: sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==} + engines: {node: '>=18'} + gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + gopd@1.2.0: + resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} + engines: {node: '>= 0.4'} + graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -2753,6 +2721,10 @@ packages: resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} engines: {node: '>= 0.4'} + has-symbols@1.1.0: + resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} + engines: {node: '>= 0.4'} + has-tostringtag@1.0.2: resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} engines: {node: '>= 0.4'} @@ -2768,10 +2740,6 @@ packages: resolution: {integrity: sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==} engines: {node: ^16.14.0 || >=18.0.0} - hosted-git-info@8.0.2: - resolution: {integrity: sha512-sYKnA7eGln5ov8T8gnYlkSOxFJvywzEx9BueN6xo/GKO8PGiI6uK6xx+DIGe45T3bdVjLAQDQW1aicT8z8JwQg==} - engines: {node: ^18.17.0 || >=20.5.0} - html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} @@ -2802,14 +2770,14 @@ packages: resolution: {integrity: sha512-VuuG0wCnjhnylG1ABXT3dAuIpTNDs/G8jlpmwXY03fXoXy/8ZK8/T+hMzt8L4WnrLCJgdybqgPagnF/f97cg3A==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - ignore-walk@7.0.0: - resolution: {integrity: sha512-T4gbf83A4NH95zvhVYZc+qWocBBGlpzUXLPGurJggw/WIOwicfXJChLDP/iBZnN5WqROSu5Bm3hhle4z8a8YGQ==} - engines: {node: ^18.17.0 || >=20.5.0} - ignore@5.3.2: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.3: + resolution: {integrity: sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA==} + engines: {node: '>= 4'} + import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -2840,10 +2808,6 @@ packages: resolution: {integrity: sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - ini@5.0.0: - resolution: {integrity: sha512-+N0ngpO3e7cRUWOJAS7qw0IZIVc6XPrW4MlFBdD066F2L4k1L6ker3hLqSq7iXxU5tgS4WGkIUElWn5vogAEnw==} - engines: {node: ^18.17.0 || >=20.5.0} - internal-slot@1.0.7: resolution: {integrity: sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==} engines: {node: '>= 0.4'} @@ -2897,9 +2861,9 @@ packages: resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} engines: {node: '>= 0.4'} - is-docker@2.2.1: - resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} - engines: {node: '>=8'} + is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} hasBin: true is-extglob@2.1.1: @@ -2914,6 +2878,11 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + is-interactive@2.0.0: resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} engines: {node: '>=12'} @@ -2998,9 +2967,9 @@ packages: resolution: {integrity: sha512-LvIm3/KWzS9oRFHugab7d+M/GcBXuXX5xZkzPmN+NxihdQlZUQ4dWuSV1xR/sq6upL1TJEDrfBgRepHFdBtSNQ==} engines: {node: '>= 0.4'} - is-wsl@2.2.0: - resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} - engines: {node: '>=8'} + is-wsl@3.1.0: + resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} + engines: {node: '>=16'} isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -3034,8 +3003,8 @@ packages: resolution: {integrity: sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==} engines: {node: 20 || >=22} - jackspeak@4.0.2: - resolution: {integrity: sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==} + jackspeak@4.1.0: + resolution: {integrity: sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw==} engines: {node: 20 || >=22} js-tokens@4.0.0: @@ -3067,10 +3036,6 @@ packages: resolution: {integrity: sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - json-parse-even-better-errors@4.0.0: - resolution: {integrity: sha512-lR4MXjGNgkJc7tkQ97kb2nuEMnNCyU//XYVH0MKTGcXEiSudQ5MKGKen3C5QubYy0vmq+JGitUg92uuywGEwIA==} - engines: {node: ^18.17.0 || >=20.5.0} - json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -3080,9 +3045,6 @@ packages: json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} - json-stringify-nice@1.1.4: - resolution: {integrity: sha512-5Z5RFW63yxReJ7vANgW6eZFGWaQvnPE3WNmZoOJrSkGju2etKA2L5rrOa1sm877TVTFt57A80BH1bArcmlLfPw==} - json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} hasBin: true @@ -3101,12 +3063,6 @@ packages: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} engines: {node: '>=12', npm: '>=6'} - just-diff-apply@5.5.0: - resolution: {integrity: sha512-OYTthRfSh55WOItVqwpefPtNt2VdKsq5AnAK6apdtR6yCH8pr0CmSr710J0Mf+WdQy7K/OzMy7K2MgAfdQURDw==} - - just-diff@6.0.2: - resolution: {integrity: sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==} - jwa@1.4.1: resolution: {integrity: sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==} @@ -3211,15 +3167,15 @@ packages: resolution: {integrity: sha512-cKTUFc/rbKUd/9meOvgrpJ2WrNzymt6jfRDdwg5UCnVzv9dTpEj9JS5m3wtziXVCjluIXyL8pcaukYqezIzZQA==} engines: {node: ^16.14.0 || >=18.0.0} - make-fetch-happen@14.0.3: - resolution: {integrity: sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ==} - engines: {node: ^18.17.0 || >=20.5.0} - marked@15.0.7: resolution: {integrity: sha512-dgLIeKGLx5FwziAnsk4ONoGwHwGPJzselimvlVskE9XLN4Orv9u2VA3GWw/lYUqjfA0rUT/6fqKwfZJapP9BEg==} engines: {node: '>= 18'} hasBin: true + math-intrinsics@1.1.0: + resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} + engines: {node: '>= 0.4'} + mdurl@1.0.1: resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==} @@ -3289,10 +3245,6 @@ packages: resolution: {integrity: sha512-2N8elDQAtSnFV0Dk7gt15KHsS0Fyz6CbYZ360h0WTYV1Ty46li3rAXVOQj1THMNLdmrD9Vt5pBPtWtVkpwGBqg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - minipass-fetch@4.0.1: - resolution: {integrity: sha512-j7U11C5HXigVuutxebFadoYBbd7VSdZWggSe64NVdvWNBqGAiXPL2QVCehjmw7lY1oF9gOllYbORh+hiNgfPgQ==} - engines: {node: ^18.17.0 || >=20.5.0} - minipass-flush@1.0.5: resolution: {integrity: sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==} engines: {node: '>= 8'} @@ -3373,10 +3325,6 @@ packages: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} - negotiator@1.0.0: - resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==} - engines: {node: '>= 0.6'} - node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -3399,11 +3347,6 @@ packages: engines: {node: ^16.14.0 || >=18.0.0} hasBin: true - node-gyp@11.1.0: - resolution: {integrity: sha512-/+7TuHKnBpnMvUQnsYEb0JOozDZqarQbfNuSGLXIjhStMT0fbw7IdSqWgopOP5xhRZE+lsbIvAHcekddruPZgQ==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - node-releases@2.0.18: resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==} @@ -3412,11 +3355,6 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} hasBin: true - nopt@8.1.0: - resolution: {integrity: sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -3428,46 +3366,22 @@ packages: resolution: {integrity: sha512-+AvaheE/ww1JEwRHOrn4WHNzOxGtVp+adrg2AeZS/7KuxGUYFuBta98wYpfHBbJp6Tg6j1NKSEVHNcfZzJHQwQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - npm-bundled@4.0.0: - resolution: {integrity: sha512-IxaQZDMsqfQ2Lz37VvyyEtKLe8FsRZuysmedy/N06TU1RyVppYKXrO4xIhR0F+7ubIBox6Q7nir6fQI3ej39iA==} - engines: {node: ^18.17.0 || >=20.5.0} - npm-install-checks@6.3.0: resolution: {integrity: sha512-W29RiK/xtpCGqn6f3ixfRYGk+zRyr+Ew9F2E20BfXxT5/euLdA/Nm7fO7OeTGuAmTs30cpgInyJ0cYe708YTZw==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - npm-install-checks@7.1.1: - resolution: {integrity: sha512-u6DCwbow5ynAX5BdiHQ9qvexme4U3qHW3MWe5NqH+NeBm0LbiH6zvGjNNew1fY+AZZUtVHbOPF3j7mJxbUzpXg==} - engines: {node: ^18.17.0 || >=20.5.0} - npm-normalize-package-bin@3.0.1: resolution: {integrity: sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - npm-normalize-package-bin@4.0.0: - resolution: {integrity: sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==} - engines: {node: ^18.17.0 || >=20.5.0} - npm-package-arg@11.0.3: resolution: {integrity: sha512-sHGJy8sOC1YraBywpzQlIKBE4pBbGbiF95U6Auspzyem956E0+FtDtsx1ZxlOJkQCZ1AFXAY/yuvtFYrOxF+Bw==} engines: {node: ^16.14.0 || >=18.0.0} - npm-package-arg@12.0.2: - resolution: {integrity: sha512-f1NpFjNI9O4VbKMOlA5QoBq/vSQPORHcTZ2feJpFkTHJ9eQkdlmZEKSjcAhxTGInC7RlEyScT9ui67NaOsjFWA==} - engines: {node: ^18.17.0 || >=20.5.0} - npm-packlist@8.0.2: resolution: {integrity: sha512-shYrPFIS/JLP4oQmAwDyk5HcyysKW8/JLTEA32S0Z5TzvpaeeX2yMFfoK1fjEBnCBvVyIB/Jj/GBFdm0wsgzbA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - npm-packlist@9.0.0: - resolution: {integrity: sha512-8qSayfmHJQTx3nJWYbbUmflpyarbLMBc6LCAjYsiGtXxDB68HaZpb8re6zeaLGxZzDuMdhsg70jryJe+RrItVQ==} - engines: {node: ^18.17.0 || >=20.5.0} - - npm-pick-manifest@10.0.0: - resolution: {integrity: sha512-r4fFa4FqYY8xaM7fHecQ9Z2nE9hgNfJR+EmoKv0+chvzWkBcORX3r0FpTByP+CbOVJDladMXnPQGVN8PBLGuTQ==} - engines: {node: ^18.17.0 || >=20.5.0} - npm-pick-manifest@9.1.0: resolution: {integrity: sha512-nkc+3pIIhqHVQr085X9d2JzPzLyjzQS96zbruppqC9aZRm/x8xx6xhI98gHtsfELP2bE+loHq8ZaHFHhe+NauA==} engines: {node: ^16.14.0 || >=18.0.0} @@ -3476,10 +3390,6 @@ packages: resolution: {integrity: sha512-5+bKQRH0J1xG1uZ1zMNvxW0VEyoNWgJpY9UDuluPFLKDfJ9u2JmmjmTJV1srBGQOROfdBMiVvnH2Zvpbm+xkVA==} engines: {node: ^16.14.0 || >=18.0.0} - npm-registry-fetch@18.0.2: - resolution: {integrity: sha512-LeVMZBBVy+oQb5R6FDV9OlJCcWDU+al10oKpe+nsvcHnG24Z3uM3SvJYKfGJlfGjVU8v9liejCrUR/M5HO5NEQ==} - engines: {node: ^18.17.0 || >=20.5.0} - object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -3538,9 +3448,9 @@ packages: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} - open@8.4.2: - resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} - engines: {node: '>=12'} + open@10.1.0: + resolution: {integrity: sha512-mnkeQ1qP5Ue2wd+aivTD3NHd/lZ96Lu0jgf0pwktLPtx6cTZiH7tyeGRRHs0zX0rbrahXPnXlUnbeXyaBBuIaw==} + engines: {node: '>=18'} optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} @@ -3582,10 +3492,6 @@ packages: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} engines: {node: '>=10'} - p-map@7.0.3: - resolution: {integrity: sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==} - engines: {node: '>=18'} - p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -3598,16 +3504,6 @@ packages: engines: {node: ^16.14.0 || >=18.0.0} hasBin: true - pacote@19.0.1: - resolution: {integrity: sha512-zIpxWAsr/BvhrkSruspG8aqCQUUrWtpwx0GjiRZQhEM/pZXrigA32ElN3vTcCPUDOFmHr6SFxwYrvVUs5NTEUg==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - - pacote@20.0.0: - resolution: {integrity: sha512-pRjC5UFwZCgx9kUFDVM9YEahv4guZ1nSLqwmWiLUnDbGsjs+U5w7z6Uc8HNR1a6x8qnu5y9xtGE6D1uAuYz+0A==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -3616,10 +3512,6 @@ packages: resolution: {integrity: sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==} engines: {node: '>=8'} - parse-conflict-json@4.0.0: - resolution: {integrity: sha512-37CN2VtcuvKgHUs8+0b1uJeEsbGn61GRHz469C94P5xiOoqpDYJYwjg4RY9Vmz39WyZAVkR5++nbJwLMIgOCnQ==} - engines: {node: ^18.17.0 || >=20.5.0} - parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -3669,6 +3561,10 @@ packages: resolution: {integrity: sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==} engines: {node: '>=12'} + path-type@6.0.0: + resolution: {integrity: sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==} + engines: {node: '>=18'} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -3694,10 +3590,6 @@ packages: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} - postcss-selector-parser@6.1.2: - resolution: {integrity: sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==} - engines: {node: '>=4'} - postcss@8.4.47: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} @@ -3711,8 +3603,8 @@ packages: engines: {node: '>=14'} hasBin: true - prettier@3.4.2: - resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} + prettier@3.5.3: + resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==} engines: {node: '>=14'} hasBin: true @@ -3720,23 +3612,9 @@ packages: resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - proc-log@5.0.0: - resolution: {integrity: sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ==} - engines: {node: ^18.17.0 || >=20.5.0} - process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - proggy@3.0.0: - resolution: {integrity: sha512-QE8RApCM3IaRRxVzxrjbgNMpQEX6Wu0p0KBeoSiSEw5/bsGwZHsshF4LCxH2jp/r6BU+bqA3LrMDEYNfJnpD8Q==} - engines: {node: ^18.17.0 || >=20.5.0} - - promise-all-reject-late@1.0.1: - resolution: {integrity: sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==} - - promise-call-limit@3.0.2: - resolution: {integrity: sha512-mRPQO2T1QQVw11E7+UdCJu7S61eJVWknzml9sC1heAdj1jxl0fWMBypIt9ZOcLFf8FkG995ZD7RnVk7HH72fZw==} - promise-inflight@1.0.1: resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==} peerDependencies: @@ -3786,14 +3664,6 @@ packages: resolution: {integrity: sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==} engines: {node: '>= 0.8'} - read-cmd-shim@5.0.0: - resolution: {integrity: sha512-SEbJV7tohp3DAAILbEMPXavBjAnMN0tVnh4+9G8ihV4Pq3HYF9h8QNez9zkJ1ILkv9G2BjdzwctznGZXgu/HGw==} - engines: {node: ^18.17.0 || >=20.5.0} - - read-package-json-fast@4.0.0: - resolution: {integrity: sha512-qpt8EwugBWDw2cgE2W+/3oxC+KTez2uSVR8JU9Q36TXPAGCaozfQUs59v4j4GFpWTaw0i6hAZSvOmu1J0uOEUg==} - engines: {node: ^18.17.0 || >=20.5.0} - read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -3883,6 +3753,10 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-applescript@7.0.0: + resolution: {integrity: sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==} + engines: {node: '>=18'} + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -3923,6 +3797,11 @@ packages: engines: {node: '>=10'} hasBin: true + semver@7.7.1: + resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + engines: {node: '>=10'} + hasBin: true + send@0.19.0: resolution: {integrity: sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==} engines: {node: '>= 0.8.0'} @@ -3968,10 +3847,6 @@ packages: resolution: {integrity: sha512-8G+/XDU8wNsJOQS5ysDVO0Etg9/2uA5gR9l4ZwijjlwxBcrU6RPfwi2+jJmbP+Ap1Hlp/nVAaEO4Fj22/SL2gQ==} engines: {node: ^16.14.0 || >=18.0.0} - sigstore@3.1.0: - resolution: {integrity: sha512-ZpzWAFHIFqyFE56dXqgX/DkDRZdz+rRcjoIk/RQU4IX0wiCv1l8S7ZrXDHcCc+uaf+6o7w3h2l3g6GYG5TKN9Q==} - engines: {node: ^18.17.0 || >=20.5.0} - simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} @@ -4024,10 +3899,6 @@ packages: resolution: {integrity: sha512-MGrFH9Z4NP9Iyhqn16sDtBpRRNJ0Y2hNa6D65h736fVSaPCHr4DM4sWUNvVaSuC+0OBGhwsrydQwmgfg5LncqQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - ssri@12.0.0: - resolution: {integrity: sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ==} - engines: {node: ^18.17.0 || >=20.5.0} - stack-trace@0.0.10: resolution: {integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==} @@ -4197,10 +4068,6 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - treeverse@3.0.0: - resolution: {integrity: sha512-gcANaAnd2QDZFmHFEOF4k7uc1J/6a6z3DJMd/QwEyxLoKGiptJRwid582r7QIsFlFMIZ3SnxfS52S4hm2DHkuQ==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - triple-beam@1.4.1: resolution: {integrity: sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==} engines: {node: '>= 14.0.0'} @@ -4235,10 +4102,6 @@ packages: resolution: {integrity: sha512-GwIJau9XaA8nLVbUXsN3IlFi7WmQ48gBUrl3FTkkL/XLu/POhBzfmX9hd33FNMX1qAsfl6ozO1iMmW9NC8YniA==} engines: {node: ^16.14.0 || >=18.0.0} - tuf-js@3.0.1: - resolution: {integrity: sha512-+68OP1ZzSF84rTckf3FA95vJ1Zlx/uaXyiiKyPd1pA4rZNkpEvDAKmsu1xUSmbF/chCRYgZ6UZkDwC7PmzmAyA==} - engines: {node: ^18.17.0 || >=20.5.0} - tunnel@0.0.6: resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} @@ -4340,22 +4203,18 @@ packages: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} + unicorn-magic@0.3.0: + resolution: {integrity: sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==} + engines: {node: '>=18'} + unique-filename@3.0.0: resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - unique-filename@4.0.0: - resolution: {integrity: sha512-XSnEewXmQ+veP7xX2dS5Q4yZAvO40cBN2MWkJ7D/6sW4Dg6wYBNwM1Vrnz1FhH5AdeLIlUXRI9e28z1YZi71NQ==} - engines: {node: ^18.17.0 || >=20.5.0} - unique-slug@4.0.0: resolution: {integrity: sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - unique-slug@5.0.0: - resolution: {integrity: sha512-9OdaqO5kwqR+1kVgHAhsp5vPNU0hnxRa26rBFNfNgM7M6pNtgzeBn3s/xbyCQL3dcjzOatcef6UUHpB/6MaETg==} - engines: {node: ^18.17.0 || >=20.5.0} - unique-string@3.0.0: resolution: {integrity: sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==} engines: {node: '>=12'} @@ -4408,10 +4267,6 @@ packages: resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - validate-npm-package-name@6.0.0: - resolution: {integrity: sha512-d7KLgL1LD3U3fgnvWEY1cQXoO/q6EQ1BSz48Sa149V/5zVTAbgmZIpyI8TRi6U9/JNyeYLlTKsEMPtLC27RFUg==} - engines: {node: ^18.17.0 || >=20.5.0} - vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -4500,9 +4355,6 @@ packages: vscode-uri@3.1.0: resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==} - walk-up-path@3.0.1: - resolution: {integrity: sha512-9YlCL/ynK3CTlrSRrDxZvUauLzAswPCrsaCgilqFevUYpeEW0/3ScEjaa3kbW/T0ghhkEr7mv+fpjqn1Y1YuTA==} - web-streams-polyfill@3.3.3: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} @@ -4534,11 +4386,6 @@ packages: engines: {node: ^16.13.0 || >=18.0.0} hasBin: true - which@5.0.0: - resolution: {integrity: sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==} - engines: {node: ^18.17.0 || >=20.5.0} - hasBin: true - why-is-node-running@2.3.0: resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} engines: {node: '>=8'} @@ -4582,10 +4429,6 @@ packages: write-file-atomic@3.0.3: resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==} - write-file-atomic@6.0.0: - resolution: {integrity: sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==} - engines: {node: ^18.17.0 || >=20.5.0} - ws@8.18.1: resolution: {integrity: sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==} engines: {node: '>=10.0.0'} @@ -4678,16 +4521,16 @@ snapshots: command-exists: 1.2.9 semver: 7.6.3 - '@azure-tools/azure-http-specs@0.1.0-alpha.7(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@types/node@22.5.5)(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': + '@azure-tools/azure-http-specs@0.1.0-alpha.9(hxmxu44wsiwmqbpvyuomrsmujq)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/spec-api': 0.1.0-alpha.1 - '@typespec/spector': 0.1.0-alpha.8(@types/node@22.5.5) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/xml': 0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/spec-api': 0.1.0-alpha.3-dev.0 + '@typespec/spector': 0.1.0-alpha.9(@types/node@22.5.5)(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/xml': 0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)) transitivePeerDependencies: - '@types/express' - '@types/node' @@ -4695,98 +4538,104 @@ snapshots: - debug - supports-color - '@azure-tools/typespec-autorest@0.52.0(3rl4rvlhrau42sgbqnofgdnzru)': + '@azure-tools/typespec-autorest@0.53.0(nzqsibdudqbld3r7bpinzdupvm)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(3gv5j4bbl2jtmj53euvpetu3oa) + '@azure-tools/typespec-client-generator-core': 0.53.0(vvgwrzozbt5d3w3ee557dp5xuy) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) - '@azure-tools/typespec-autorest@0.52.0(6uu33tjguzoy44vb3pkhjaszly)': + '@azure-tools/typespec-autorest@0.53.0(vsru7ipd7qt42slknz5aanwsou)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(felt6lfzt5orrlwrzxpkykwppa) + '@azure-tools/typespec-client-generator-core': 0.53.0(3qm5ewpnxvwkav6ttg6x7temqm) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) - '@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))': + '@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) - '@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))': + '@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) - '@azure-tools/typespec-azure-resource-manager@0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))': + '@azure-tools/typespec-azure-resource-manager@0.53.0(3gv5j4bbl2jtmj53euvpetu3oa)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))) - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) change-case: 5.4.4 pluralize: 8.0.0 - '@azure-tools/typespec-azure-resource-manager@0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': + '@azure-tools/typespec-azure-resource-manager@0.53.0(felt6lfzt5orrlwrzxpkykwppa)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) change-case: 5.4.4 pluralize: 8.0.0 - '@azure-tools/typespec-azure-rulesets@0.52.0(eqsyztd2tvlx3c3vm7av2vzyaa)': + '@azure-tools/typespec-azure-rulesets@0.53.0(@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))))(@azure-tools/typespec-azure-resource-manager@0.53.0(3gv5j4bbl2jtmj53euvpetu3oa))(@azure-tools/typespec-client-generator-core@0.53.0(vvgwrzozbt5d3w3ee557dp5xuy))(@typespec/compiler@0.67.1(@types/node@22.13.10))': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/compiler': 0.66.0(@types/node@22.10.10) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(3gv5j4bbl2jtmj53euvpetu3oa) + '@azure-tools/typespec-client-generator-core': 0.53.0(vvgwrzozbt5d3w3ee557dp5xuy) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) - '@azure-tools/typespec-azure-rulesets@0.52.0(hnvyb6ssbaiolad3f2jkopuscy)': + '@azure-tools/typespec-azure-rulesets@0.53.0(@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))))(@azure-tools/typespec-azure-resource-manager@0.53.0(felt6lfzt5orrlwrzxpkykwppa))(@azure-tools/typespec-client-generator-core@0.53.0(3qm5ewpnxvwkav6ttg6x7temqm))(@typespec/compiler@0.67.1(@types/node@22.5.5))': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(felt6lfzt5orrlwrzxpkykwppa) + '@azure-tools/typespec-client-generator-core': 0.53.0(3qm5ewpnxvwkav6ttg6x7temqm) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) - '@azure-tools/typespec-client-generator-core@0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))': + '@azure-tools/typespec-client-generator-core@0.53.0(3qm5ewpnxvwkav6ttg6x7temqm)': dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))) - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/xml': 0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/events': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/sse': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/xml': 0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)) change-case: 5.4.4 pluralize: 8.0.0 yaml: 2.7.0 - '@azure-tools/typespec-client-generator-core@0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': - dependencies: - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/xml': 0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@azure-tools/typespec-client-generator-core@0.53.0(vvgwrzozbt5d3w3ee557dp5xuy)': + dependencies: + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/events': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/sse': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) + '@typespec/xml': 0.59.0(@typespec/compiler@0.67.1(@types/node@22.13.10)) change-case: 5.4.4 pluralize: 8.0.0 yaml: 2.7.0 @@ -4798,7 +4647,7 @@ snapshots: '@azure/core-auth@1.8.0': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 tslib: 2.7.0 '@azure/core-auth@1.9.0': @@ -4810,10 +4659,10 @@ snapshots: '@azure/core-client@1.9.2': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-auth': 1.8.0 + '@azure/core-auth': 1.9.0 '@azure/core-rest-pipeline': 1.17.0 '@azure/core-tracing': 1.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 tslib: 2.7.0 transitivePeerDependencies: @@ -4830,7 +4679,7 @@ snapshots: '@azure/core-lro@2.7.2': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 tslib: 2.7.0 @@ -4841,9 +4690,9 @@ snapshots: '@azure/core-rest-pipeline@1.17.0': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-auth': 1.8.0 + '@azure/core-auth': 1.9.0 '@azure/core-tracing': 1.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 http-proxy-agent: 7.0.2 https-proxy-agent: 7.0.5 @@ -4870,7 +4719,7 @@ snapshots: fast-xml-parser: 4.5.0 tslib: 2.7.0 - '@azure/identity@4.6.0': + '@azure/identity@4.7.0': dependencies: '@azure/abort-controller': 2.1.2 '@azure/core-auth': 1.9.0 @@ -4880,10 +4729,10 @@ snapshots: '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 '@azure/msal-browser': 4.5.1 - '@azure/msal-node': 2.16.2 + '@azure/msal-node': 3.3.0 events: 3.3.0 jws: 4.0.0 - open: 8.4.2 + open: 10.1.0 stoppable: 1.1.0 tslib: 2.7.0 transitivePeerDependencies: @@ -4897,13 +4746,13 @@ snapshots: dependencies: '@azure/msal-common': 15.2.0 - '@azure/msal-common@14.16.0': {} - '@azure/msal-common@15.2.0': {} - '@azure/msal-node@2.16.2': + '@azure/msal-common@15.2.1': {} + + '@azure/msal-node@3.3.0': dependencies: - '@azure/msal-common': 14.16.0 + '@azure/msal-common': 15.2.1 jsonwebtoken: 9.0.2 uuid: 8.3.2 @@ -4928,14 +4777,14 @@ snapshots: '@azure/storage-blob@12.26.0': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-auth': 1.8.0 + '@azure/core-auth': 1.9.0 '@azure/core-client': 1.9.2 '@azure/core-http-compat': 2.1.2 '@azure/core-lro': 2.7.2 '@azure/core-paging': 1.6.2 '@azure/core-rest-pipeline': 1.17.0 '@azure/core-tracing': 1.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/core-xml': 1.4.3 '@azure/logger': 1.1.4 events: 3.3.0 @@ -4946,7 +4795,7 @@ snapshots: '@babel/code-frame@7.24.7': dependencies: '@babel/highlight': 7.24.7 - picocolors: 1.1.0 + picocolors: 1.1.1 '@babel/code-frame@7.26.2': dependencies: @@ -4960,10 +4809,10 @@ snapshots: '@babel/highlight@7.24.7': dependencies: - '@babel/helper-validator-identifier': 7.24.7 + '@babel/helper-validator-identifier': 7.25.9 chalk: 2.4.2 js-tokens: 4.0.0 - picocolors: 1.1.0 + picocolors: 1.1.1 '@bcoe/v8-coverage@1.0.2': {} @@ -4994,13 +4843,13 @@ snapshots: is-unicode-supported: 2.1.0 micromatch: 4.0.8 pacote: 18.0.6 - picocolors: 1.1.0 + picocolors: 1.1.1 pluralize: 8.0.0 prompts: 2.4.2 semver: 7.6.3 source-map-support: 0.5.21 std-env: 3.7.0 - yaml: 2.5.1 + yaml: 2.7.0 yargs: 17.7.2 zod: 3.23.8 transitivePeerDependencies: @@ -5362,7 +5211,7 @@ snapshots: '@eslint/config-array@0.18.0': dependencies: '@eslint/object-schema': 2.1.4 - debug: 4.3.7 + debug: 4.4.0 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -5372,7 +5221,7 @@ snapshots: '@eslint/eslintrc@3.1.0': dependencies: ajv: 6.12.6 - debug: 4.3.7 + debug: 4.4.0 espree: 10.1.0 globals: 14.0.0 ignore: 5.3.2 @@ -5397,15 +5246,15 @@ snapshots: '@humanwhocodes/retry@0.3.0': {} - '@inquirer/checkbox@4.1.2(@types/node@22.10.10)': + '@inquirer/checkbox@4.1.2(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) '@inquirer/figures': 1.0.10 - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/checkbox@4.1.2(@types/node@22.5.5)': dependencies: @@ -5417,12 +5266,12 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/confirm@5.1.6(@types/node@22.10.10)': + '@inquirer/confirm@5.1.6(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/confirm@5.1.6(@types/node@22.5.5)': dependencies: @@ -5431,10 +5280,10 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/core@10.1.7(@types/node@22.10.10)': + '@inquirer/core@10.1.7(@types/node@22.13.10)': dependencies: '@inquirer/figures': 1.0.10 - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) ansi-escapes: 4.3.2 cli-width: 4.1.0 mute-stream: 2.0.0 @@ -5442,7 +5291,7 @@ snapshots: wrap-ansi: 6.2.0 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/core@10.1.7(@types/node@22.5.5)': dependencies: @@ -5457,13 +5306,13 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/editor@4.2.7(@types/node@22.10.10)': + '@inquirer/editor@4.2.7(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) external-editor: 3.1.0 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/editor@4.2.7(@types/node@22.5.5)': dependencies: @@ -5473,13 +5322,13 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/expand@4.0.9(@types/node@22.10.10)': + '@inquirer/expand@4.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/expand@4.0.9(@types/node@22.5.5)': dependencies: @@ -5491,12 +5340,12 @@ snapshots: '@inquirer/figures@1.0.10': {} - '@inquirer/input@4.1.6(@types/node@22.10.10)': + '@inquirer/input@4.1.6(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/input@4.1.6(@types/node@22.5.5)': dependencies: @@ -5505,12 +5354,12 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/number@3.0.9(@types/node@22.10.10)': + '@inquirer/number@3.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/number@3.0.9(@types/node@22.5.5)': dependencies: @@ -5519,13 +5368,13 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/password@4.0.9(@types/node@22.10.10)': + '@inquirer/password@4.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) ansi-escapes: 4.3.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/password@4.0.9(@types/node@22.5.5)': dependencies: @@ -5535,20 +5384,20 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/prompts@7.3.2(@types/node@22.10.10)': - dependencies: - '@inquirer/checkbox': 4.1.2(@types/node@22.10.10) - '@inquirer/confirm': 5.1.6(@types/node@22.10.10) - '@inquirer/editor': 4.2.7(@types/node@22.10.10) - '@inquirer/expand': 4.0.9(@types/node@22.10.10) - '@inquirer/input': 4.1.6(@types/node@22.10.10) - '@inquirer/number': 3.0.9(@types/node@22.10.10) - '@inquirer/password': 4.0.9(@types/node@22.10.10) - '@inquirer/rawlist': 4.0.9(@types/node@22.10.10) - '@inquirer/search': 3.0.9(@types/node@22.10.10) - '@inquirer/select': 4.0.9(@types/node@22.10.10) + '@inquirer/prompts@7.3.2(@types/node@22.13.10)': + dependencies: + '@inquirer/checkbox': 4.1.2(@types/node@22.13.10) + '@inquirer/confirm': 5.1.6(@types/node@22.13.10) + '@inquirer/editor': 4.2.7(@types/node@22.13.10) + '@inquirer/expand': 4.0.9(@types/node@22.13.10) + '@inquirer/input': 4.1.6(@types/node@22.13.10) + '@inquirer/number': 3.0.9(@types/node@22.13.10) + '@inquirer/password': 4.0.9(@types/node@22.13.10) + '@inquirer/rawlist': 4.0.9(@types/node@22.13.10) + '@inquirer/search': 3.0.9(@types/node@22.13.10) + '@inquirer/select': 4.0.9(@types/node@22.13.10) optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/prompts@7.3.2(@types/node@22.5.5)': dependencies: @@ -5565,13 +5414,13 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/rawlist@4.0.9(@types/node@22.10.10)': + '@inquirer/rawlist@4.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/rawlist@4.0.9(@types/node@22.5.5)': dependencies: @@ -5581,14 +5430,14 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/search@3.0.9(@types/node@22.10.10)': + '@inquirer/search@3.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) '@inquirer/figures': 1.0.10 - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/search@3.0.9(@types/node@22.5.5)': dependencies: @@ -5599,15 +5448,15 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/select@4.0.9(@types/node@22.10.10)': + '@inquirer/select@4.0.9(@types/node@22.13.10)': dependencies: - '@inquirer/core': 10.1.7(@types/node@22.10.10) + '@inquirer/core': 10.1.7(@types/node@22.13.10) '@inquirer/figures': 1.0.10 - '@inquirer/type': 3.0.4(@types/node@22.10.10) + '@inquirer/type': 3.0.4(@types/node@22.13.10) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/select@4.0.9(@types/node@22.5.5)': dependencies: @@ -5619,9 +5468,9 @@ snapshots: optionalDependencies: '@types/node': 22.5.5 - '@inquirer/type@3.0.4(@types/node@22.10.10)': + '@inquirer/type@3.0.4(@types/node@22.13.10)': optionalDependencies: - '@types/node': 22.10.10 + '@types/node': 22.13.10 '@inquirer/type@3.0.4(@types/node@22.5.5)': optionalDependencies: @@ -5640,8 +5489,6 @@ snapshots: dependencies: minipass: 7.1.2 - '@isaacs/string-locale-compare@1.1.0': {} - '@istanbuljs/schema@0.1.3': {} '@jridgewell/resolve-uri@3.1.2': {} @@ -5697,61 +5544,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@npmcli/agent@3.0.0': - dependencies: - agent-base: 7.1.1 - http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.5 - lru-cache: 10.4.3 - socks-proxy-agent: 8.0.4 - transitivePeerDependencies: - - supports-color - - '@npmcli/arborist@8.0.0': - dependencies: - '@isaacs/string-locale-compare': 1.1.0 - '@npmcli/fs': 4.0.0 - '@npmcli/installed-package-contents': 3.0.0 - '@npmcli/map-workspaces': 4.0.2 - '@npmcli/metavuln-calculator': 8.0.1 - '@npmcli/name-from-folder': 3.0.0 - '@npmcli/node-gyp': 4.0.0 - '@npmcli/package-json': 6.1.1 - '@npmcli/query': 4.0.0 - '@npmcli/redact': 3.1.1 - '@npmcli/run-script': 9.0.2 - bin-links: 5.0.0 - cacache: 19.0.1 - common-ancestor-path: 1.0.1 - hosted-git-info: 8.0.2 - json-parse-even-better-errors: 4.0.0 - json-stringify-nice: 1.1.4 - lru-cache: 10.4.3 - minimatch: 9.0.5 - nopt: 8.1.0 - npm-install-checks: 7.1.1 - npm-package-arg: 12.0.2 - npm-pick-manifest: 10.0.0 - npm-registry-fetch: 18.0.2 - pacote: 19.0.1 - parse-conflict-json: 4.0.0 - proc-log: 5.0.0 - proggy: 3.0.0 - promise-all-reject-late: 1.0.1 - promise-call-limit: 3.0.2 - read-package-json-fast: 4.0.0 - semver: 7.6.3 - ssri: 12.0.0 - treeverse: 3.0.0 - walk-up-path: 3.0.1 - transitivePeerDependencies: - - supports-color - - '@npmcli/fs@3.1.1': - dependencies: - semver: 7.6.3 - - '@npmcli/fs@4.0.0': + '@npmcli/fs@3.1.1': dependencies: semver: 7.6.3 @@ -5769,50 +5562,13 @@ snapshots: transitivePeerDependencies: - bluebird - '@npmcli/git@6.0.3': - dependencies: - '@npmcli/promise-spawn': 8.0.2 - ini: 5.0.0 - lru-cache: 10.4.3 - npm-pick-manifest: 10.0.0 - proc-log: 5.0.0 - promise-retry: 2.0.1 - semver: 7.6.3 - which: 5.0.0 - '@npmcli/installed-package-contents@2.1.0': dependencies: npm-bundled: 3.0.1 npm-normalize-package-bin: 3.0.1 - '@npmcli/installed-package-contents@3.0.0': - dependencies: - npm-bundled: 4.0.0 - npm-normalize-package-bin: 4.0.0 - - '@npmcli/map-workspaces@4.0.2': - dependencies: - '@npmcli/name-from-folder': 3.0.0 - '@npmcli/package-json': 6.1.1 - glob: 10.4.5 - minimatch: 9.0.5 - - '@npmcli/metavuln-calculator@8.0.1': - dependencies: - cacache: 19.0.1 - json-parse-even-better-errors: 4.0.0 - pacote: 20.0.0 - proc-log: 5.0.0 - semver: 7.6.3 - transitivePeerDependencies: - - supports-color - - '@npmcli/name-from-folder@3.0.0': {} - '@npmcli/node-gyp@3.0.0': {} - '@npmcli/node-gyp@4.0.0': {} - '@npmcli/package-json@5.2.1': dependencies: '@npmcli/git': 5.0.8 @@ -5825,32 +5581,12 @@ snapshots: transitivePeerDependencies: - bluebird - '@npmcli/package-json@6.1.1': - dependencies: - '@npmcli/git': 6.0.3 - glob: 10.4.5 - hosted-git-info: 8.0.2 - json-parse-even-better-errors: 4.0.0 - proc-log: 5.0.0 - semver: 7.6.3 - validate-npm-package-license: 3.0.4 - '@npmcli/promise-spawn@7.0.2': dependencies: which: 4.0.0 - '@npmcli/promise-spawn@8.0.2': - dependencies: - which: 5.0.0 - - '@npmcli/query@4.0.0': - dependencies: - postcss-selector-parser: 6.1.2 - '@npmcli/redact@2.0.1': {} - '@npmcli/redact@3.1.1': {} - '@npmcli/run-script@8.1.0': dependencies: '@npmcli/node-gyp': 3.0.0 @@ -5863,17 +5599,6 @@ snapshots: - bluebird - supports-color - '@npmcli/run-script@9.0.2': - dependencies: - '@npmcli/node-gyp': 4.0.0 - '@npmcli/package-json': 6.1.1 - '@npmcli/promise-spawn': 8.0.2 - node-gyp: 11.1.0 - proc-log: 5.0.0 - which: 5.0.0 - transitivePeerDependencies: - - supports-color - '@octokit/app@15.1.0': dependencies: '@octokit/auth-app': 7.1.1 @@ -6140,18 +5865,10 @@ snapshots: dependencies: '@sigstore/protobuf-specs': 0.3.2 - '@sigstore/bundle@3.1.0': - dependencies: - '@sigstore/protobuf-specs': 0.4.0 - '@sigstore/core@1.1.0': {} - '@sigstore/core@2.0.0': {} - '@sigstore/protobuf-specs@0.3.2': {} - '@sigstore/protobuf-specs@0.4.0': {} - '@sigstore/sign@2.3.2': dependencies: '@sigstore/bundle': 2.3.2 @@ -6163,17 +5880,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@sigstore/sign@3.1.0': - dependencies: - '@sigstore/bundle': 3.1.0 - '@sigstore/core': 2.0.0 - '@sigstore/protobuf-specs': 0.4.0 - make-fetch-happen: 14.0.3 - proc-log: 5.0.0 - promise-retry: 2.0.1 - transitivePeerDependencies: - - supports-color - '@sigstore/tuf@2.3.4': dependencies: '@sigstore/protobuf-specs': 0.3.2 @@ -6181,25 +5887,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@sigstore/tuf@3.1.0': - dependencies: - '@sigstore/protobuf-specs': 0.4.0 - tuf-js: 3.0.1 - transitivePeerDependencies: - - supports-color - '@sigstore/verify@1.2.1': dependencies: '@sigstore/bundle': 2.3.2 '@sigstore/core': 1.1.0 '@sigstore/protobuf-specs': 0.3.2 - '@sigstore/verify@2.1.0': - dependencies: - '@sigstore/bundle': 3.1.0 - '@sigstore/core': 2.0.0 - '@sigstore/protobuf-specs': 0.4.0 - '@sindresorhus/merge-streams@2.3.0': {} '@tufjs/canonical-json@2.0.0': {} @@ -6209,11 +5902,6 @@ snapshots: '@tufjs/canonical-json': 2.0.0 minimatch: 9.0.5 - '@tufjs/models@3.0.1': - dependencies: - '@tufjs/canonical-json': 2.0.0 - minimatch: 9.0.5 - '@types/aws-lambda@8.10.145': {} '@types/estree@1.0.5': {} @@ -6237,7 +5925,7 @@ snapshots: dependencies: '@types/node': 22.5.5 - '@types/node@22.10.10': + '@types/node@22.13.10': dependencies: undici-types: 6.20.0 @@ -6310,7 +5998,7 @@ snapshots: '@typescript-eslint/types': 8.7.0 '@typescript-eslint/typescript-estree': 8.7.0(typescript@5.6.2) '@typescript-eslint/visitor-keys': 8.7.0 - debug: 4.3.7 + debug: 4.4.0 eslint: 9.11.1 optionalDependencies: typescript: 5.6.2 @@ -6331,7 +6019,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.26.0(typescript@5.7.3) '@typescript-eslint/utils': 8.26.0(eslint@9.11.1)(typescript@5.7.3) - debug: 4.3.7 + debug: 4.4.0 eslint: 9.11.1 ts-api-utils: 2.0.1(typescript@5.7.3) typescript: 5.7.3 @@ -6342,7 +6030,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 8.7.0(typescript@5.6.2) '@typescript-eslint/utils': 8.7.0(eslint@9.11.1)(typescript@5.6.2) - debug: 4.3.7 + debug: 4.4.0 ts-api-utils: 1.3.0(typescript@5.6.2) optionalDependencies: typescript: 5.6.2 @@ -6358,7 +6046,7 @@ snapshots: dependencies: '@typescript-eslint/types': 8.26.0 '@typescript-eslint/visitor-keys': 8.26.0 - debug: 4.3.7 + debug: 4.4.0 fast-glob: 3.3.2 is-glob: 4.0.3 minimatch: 9.0.5 @@ -6372,7 +6060,7 @@ snapshots: dependencies: '@typescript-eslint/types': 8.7.0 '@typescript-eslint/visitor-keys': 8.7.0 - debug: 4.3.7 + debug: 4.4.0 fast-glob: 3.3.2 is-glob: 4.0.3 minimatch: 9.0.5 @@ -6415,19 +6103,20 @@ snapshots: '@typescript-eslint/types': 8.7.0 eslint-visitor-keys: 3.4.3 - '@typespec/compiler@0.66.0(@types/node@22.10.10)': + '@typespec/compiler@0.67.1(@types/node@22.13.10)': dependencies: '@babel/code-frame': 7.26.2 - '@inquirer/prompts': 7.3.2(@types/node@22.10.10) - '@npmcli/arborist': 8.0.0 + '@inquirer/prompts': 7.3.2(@types/node@22.13.10) ajv: 8.17.1 change-case: 5.4.4 - globby: 14.0.2 + env-paths: 3.0.0 + globby: 14.1.0 is-unicode-supported: 2.1.0 mustache: 4.2.0 picocolors: 1.1.1 - prettier: 3.4.2 - semver: 7.6.3 + prettier: 3.5.3 + semver: 7.7.1 + tar: 7.4.3 temporal-polyfill: 0.2.5 vscode-languageserver: 9.0.1 vscode-languageserver-textdocument: 1.0.12 @@ -6435,21 +6124,21 @@ snapshots: yargs: 17.7.2 transitivePeerDependencies: - '@types/node' - - supports-color - '@typespec/compiler@0.66.0(@types/node@22.5.5)': + '@typespec/compiler@0.67.1(@types/node@22.5.5)': dependencies: '@babel/code-frame': 7.26.2 '@inquirer/prompts': 7.3.2(@types/node@22.5.5) - '@npmcli/arborist': 8.0.0 ajv: 8.17.1 change-case: 5.4.4 - globby: 14.0.2 + env-paths: 3.0.0 + globby: 14.1.0 is-unicode-supported: 2.1.0 mustache: 4.2.0 picocolors: 1.1.1 - prettier: 3.4.2 - semver: 7.6.3 + prettier: 3.5.3 + semver: 7.7.1 + tar: 7.4.3 temporal-polyfill: 0.2.5 vscode-languageserver: 9.0.1 vscode-languageserver-textdocument: 1.0.12 @@ -6457,20 +6146,27 @@ snapshots: yargs: 17.7.2 transitivePeerDependencies: - '@types/node' - - supports-color - '@typespec/http-client-python@0.8.0(okmb572npleddk7eu2wecik6ue)': - dependencies: - '@azure-tools/typespec-autorest': 0.52.0(6uu33tjguzoy44vb3pkhjaszly) - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@azure-tools/typespec-azure-rulesets': 0.52.0(eqsyztd2tvlx3c3vm7av2vzyaa) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))))(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + + '@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(xyfohv7glp6msr4ipudj2mb5ju)': + dependencies: + '@azure-tools/typespec-autorest': 0.53.0(nzqsibdudqbld3r7bpinzdupvm) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(3gv5j4bbl2jtmj53euvpetu3oa) + '@azure-tools/typespec-azure-rulesets': 0.53.0(@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))))(@azure-tools/typespec-azure-resource-manager@0.53.0(3gv5j4bbl2jtmj53euvpetu3oa))(@azure-tools/typespec-client-generator-core@0.53.0(vvgwrzozbt5d3w3ee557dp5xuy))(@typespec/compiler@0.67.1(@types/node@22.13.10)) + '@azure-tools/typespec-client-generator-core': 0.53.0(vvgwrzozbt5d3w3ee557dp5xuy) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) js-yaml: 4.1.0 marked: 15.0.7 pyodide: 0.26.2 @@ -6480,18 +6176,18 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-client-python@0.8.0(phqovtct7xb2vaqtokn2tbhedm)': - dependencies: - '@azure-tools/typespec-autorest': 0.52.0(3rl4rvlhrau42sgbqnofgdnzru) - '@azure-tools/typespec-azure-core': 0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))) - '@azure-tools/typespec-azure-resource-manager': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@azure-tools/typespec-azure-rulesets': 0.52.0(hnvyb6ssbaiolad3f2jkopuscy) - '@azure-tools/typespec-client-generator-core': 0.52.0(@azure-tools/typespec-azure-core@0.52.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))))(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/openapi': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': + dependencies: + '@azure-tools/typespec-autorest': 0.53.0(vsru7ipd7qt42slknz5aanwsou) + '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) + '@azure-tools/typespec-azure-resource-manager': 0.53.0(felt6lfzt5orrlwrzxpkykwppa) + '@azure-tools/typespec-azure-rulesets': 0.53.0(@azure-tools/typespec-azure-core@0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))))(@azure-tools/typespec-azure-resource-manager@0.53.0(felt6lfzt5orrlwrzxpkykwppa))(@azure-tools/typespec-client-generator-core@0.53.0(3qm5ewpnxvwkav6ttg6x7temqm))(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@azure-tools/typespec-client-generator-core': 0.53.0(3qm5ewpnxvwkav6ttg6x7temqm) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/openapi': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) js-yaml: 4.1.0 marked: 15.0.7 pyodide: 0.26.2 @@ -6501,15 +6197,15 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-specs@0.1.0-alpha.11(@types/node@22.5.5)(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))))(@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': + '@typespec/http-specs@0.1.0-alpha.13(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/spec-api': 0.1.0-alpha.1 - '@typespec/spector': 0.1.0-alpha.8(@types/node@22.5.5) - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/xml': 0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/spec-api': 0.1.0-alpha.3-dev.0 + '@typespec/spector': 0.1.0-alpha.9(@types/node@22.5.5)(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/xml': 0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)) transitivePeerDependencies: - '@types/express' - '@types/node' @@ -6517,35 +6213,39 @@ snapshots: - debug - supports-color - '@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))': + '@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + optionalDependencies: + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) - '@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))': + '@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + optionalDependencies: + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) - '@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))': + '@typespec/openapi@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) - '@typespec/openapi@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': + '@typespec/openapi@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) - '@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)))': + '@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10)) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) - '@typespec/rest@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)))': + '@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) - '@typespec/spec-api@0.1.0-alpha.1': + '@typespec/spec-api@0.1.0-alpha.3-dev.0': dependencies: body-parser: 1.20.3 deep-equal: 2.2.3 @@ -6554,7 +6254,7 @@ snapshots: morgan: 1.10.0 multer: 1.4.5-lts.1 picocolors: 1.1.1 - prettier: 3.4.2 + prettier: 3.5.3 winston: 3.17.0 xml2js: 0.6.2 yargs: 17.7.2 @@ -6562,33 +6262,33 @@ snapshots: - '@types/express' - supports-color - '@typespec/spec-coverage-sdk@0.1.0-alpha.3': + '@typespec/spec-coverage-sdk@0.1.0-alpha.5-dev.0': dependencies: - '@azure/identity': 4.6.0 + '@azure/identity': 4.7.0 '@azure/storage-blob': 12.26.0 - '@types/node': 22.10.10 + '@types/node': 22.13.10 transitivePeerDependencies: - supports-color - '@typespec/spector@0.1.0-alpha.8(@types/node@22.5.5)': + '@typespec/spector@0.1.0-alpha.9(@types/node@22.5.5)(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))': dependencies: - '@azure/identity': 4.6.0 + '@azure/identity': 4.7.0 '@types/js-yaml': 4.0.9 - '@typespec/compiler': 0.66.0(@types/node@22.5.5) - '@typespec/http': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) - '@typespec/rest': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))(@typespec/http@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))) - '@typespec/spec-api': 0.1.0-alpha.1 - '@typespec/spec-coverage-sdk': 0.1.0-alpha.3 - '@typespec/versioning': 0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5)) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/rest': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) + '@typespec/spec-api': 0.1.0-alpha.3-dev.0 + '@typespec/spec-coverage-sdk': 0.1.0-alpha.5-dev.0 + '@typespec/versioning': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) ajv: 8.17.1 axios: 1.8.1 body-parser: 1.20.3 deep-equal: 2.2.3 express: 4.21.2 express-promise-router: 4.1.1(express@4.21.2) - form-data: 4.0.1 - globby: 14.0.2 - jackspeak: 4.0.2 + form-data: 4.0.2 + globby: 14.1.0 + jackspeak: 4.1.0 js-yaml: 4.1.0 morgan: 1.10.0 multer: 1.4.5-lts.1 @@ -6605,21 +6305,43 @@ snapshots: - debug - supports-color - '@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.10.10))': + '@typespec/sse@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + '@typespec/events': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))) + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10)) + + '@typespec/sse@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/events@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + '@typespec/events': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) + '@typespec/streams': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)) + + '@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.13.10) + + '@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))': + dependencies: + '@typespec/compiler': 0.67.1(@types/node@22.5.5) + + '@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) - '@typespec/versioning@0.66.0(@typespec/compiler@0.66.0(@types/node@22.5.5))': + '@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) - '@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.10.10))': + '@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.13.10))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.10.10) + '@typespec/compiler': 0.67.1(@types/node@22.13.10) - '@typespec/xml@0.59.0(@typespec/compiler@0.66.0(@types/node@22.5.5))': + '@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5))': dependencies: - '@typespec/compiler': 0.66.0(@types/node@22.5.5) + '@typespec/compiler': 0.67.1(@types/node@22.5.5) '@vitest/expect@3.0.8': dependencies: @@ -6663,8 +6385,6 @@ snapshots: abbrev@2.0.0: {} - abbrev@3.0.0: {} - accepts@1.3.8: dependencies: mime-types: 2.1.35 @@ -6678,7 +6398,7 @@ snapshots: agent-base@7.1.1: dependencies: - debug: 4.3.7 + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -6792,7 +6512,7 @@ snapshots: axios@1.8.1: dependencies: follow-redirects: 1.15.9 - form-data: 4.0.1 + form-data: 4.0.2 proxy-from-env: 1.1.0 transitivePeerDependencies: - debug @@ -6807,14 +6527,6 @@ snapshots: before-after-hook@3.0.2: {} - bin-links@5.0.0: - dependencies: - cmd-shim: 7.0.0 - npm-normalize-package-bin: 4.0.0 - proc-log: 5.0.0 - read-cmd-shim: 5.0.0 - write-file-atomic: 6.0.0 - body-parser@1.20.3: dependencies: bytes: 3.1.2 @@ -6860,6 +6572,10 @@ snapshots: builtin-modules@3.3.0: {} + bundle-name@4.1.0: + dependencies: + run-applescript: 7.0.0 + busboy@1.6.0: dependencies: streamsearch: 1.1.0 @@ -6897,20 +6613,10 @@ snapshots: tar: 6.2.1 unique-filename: 3.0.0 - cacache@19.0.1: + call-bind-apply-helpers@1.0.2: dependencies: - '@npmcli/fs': 4.0.0 - fs-minipass: 3.0.3 - glob: 10.4.5 - lru-cache: 10.4.3 - minipass: 7.1.2 - minipass-collect: 2.0.1 - minipass-flush: 1.0.5 - minipass-pipeline: 1.2.4 - p-map: 7.0.3 - ssri: 12.0.0 - tar: 7.4.3 - unique-filename: 4.0.0 + es-errors: 1.3.0 + function-bind: 1.1.2 call-bind@1.0.7: dependencies: @@ -6986,8 +6692,6 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 - cmd-shim@7.0.0: {} - color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -7033,8 +6737,6 @@ snapshots: has-own-prop: 2.0.0 repeat-string: 1.6.1 - common-ancestor-path@1.0.1: {} - commonmark@0.30.0: dependencies: entities: 2.0.3 @@ -7194,8 +6896,6 @@ snapshots: transitivePeerDependencies: - encoding - cssesc@3.0.0: {} - data-uri-to-buffer@4.0.1: {} data-view-buffer@1.0.1: @@ -7257,13 +6957,20 @@ snapshots: deep-is@0.1.4: {} + default-browser-id@5.0.0: {} + + default-browser@5.2.1: + dependencies: + bundle-name: 4.1.0 + default-browser-id: 5.0.0 + define-data-property@1.1.4: dependencies: es-define-property: 1.0.0 es-errors: 1.3.0 gopd: 1.0.1 - define-lazy-prop@2.0.0: {} + define-lazy-prop@3.0.0: {} define-properties@1.2.1: dependencies: @@ -7287,6 +6994,12 @@ snapshots: dependencies: is-obj: 2.0.0 + dunder-proto@1.0.1: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-errors: 1.3.0 + gopd: 1.2.0 + eastasianwidth@0.2.0: {} ecdsa-sig-formatter@1.0.11: @@ -7325,6 +7038,8 @@ snapshots: env-paths@2.2.1: {} + env-paths@3.0.0: {} + err-code@2.0.3: {} error-ex@1.3.2: @@ -7384,6 +7099,8 @@ snapshots: dependencies: get-intrinsic: 1.2.4 + es-define-property@1.0.1: {} + es-errors@1.3.0: {} es-get-iterator@1.1.3: @@ -7404,12 +7121,23 @@ snapshots: dependencies: es-errors: 1.3.0 + es-object-atoms@1.1.1: + dependencies: + es-errors: 1.3.0 + es-set-tostringtag@2.0.3: dependencies: get-intrinsic: 1.2.4 has-tostringtag: 1.0.2 hasown: 2.0.2 + es-set-tostringtag@2.1.0: + dependencies: + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + has-tostringtag: 1.0.2 + hasown: 2.0.2 + es-shim-unscopables@1.0.2: dependencies: hasown: 2.0.2 @@ -7743,6 +7471,14 @@ snapshots: merge2: 1.4.1 micromatch: 4.0.8 + fast-glob@3.3.3: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + fast-json-stable-stringify@2.1.0: {} fast-levenshtein@2.0.6: {} @@ -7829,10 +7565,11 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 - form-data@4.0.1: + form-data@4.0.2: dependencies: asynckit: 0.4.0 combined-stream: 1.0.8 + es-set-tostringtag: 2.1.0 mime-types: 2.1.35 formdata-polyfill@4.0.10: @@ -7889,6 +7626,24 @@ snapshots: has-symbols: 1.0.3 hasown: 2.0.2 + get-intrinsic@1.3.0: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.1 + function-bind: 1.1.2 + get-proto: 1.0.1 + gopd: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.2 + math-intrinsics: 1.1.0 + + get-proto@1.0.1: + dependencies: + dunder-proto: 1.0.1 + es-object-atoms: 1.1.1 + get-stdin@9.0.0: {} get-symbol-description@1.0.2: @@ -7966,10 +7721,21 @@ snapshots: slash: 5.1.0 unicorn-magic: 0.1.0 + globby@14.1.0: + dependencies: + '@sindresorhus/merge-streams': 2.3.0 + fast-glob: 3.3.3 + ignore: 7.0.3 + path-type: 6.0.0 + slash: 5.1.0 + unicorn-magic: 0.3.0 + gopd@1.0.1: dependencies: get-intrinsic: 1.2.4 + gopd@1.2.0: {} + graceful-fs@4.2.11: {} graphemer@1.4.0: {} @@ -7990,6 +7756,8 @@ snapshots: has-symbols@1.0.3: {} + has-symbols@1.1.0: {} + has-tostringtag@1.0.2: dependencies: has-symbols: 1.0.3 @@ -8004,10 +7772,6 @@ snapshots: dependencies: lru-cache: 10.4.3 - hosted-git-info@8.0.2: - dependencies: - lru-cache: 10.4.3 - html-escaper@2.0.2: {} http-cache-semantics@4.1.1: {} @@ -8023,14 +7787,14 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.1 - debug: 4.3.7 + debug: 4.4.0 transitivePeerDependencies: - supports-color https-proxy-agent@7.0.5: dependencies: agent-base: 7.1.1 - debug: 4.3.7 + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -8047,12 +7811,10 @@ snapshots: dependencies: minimatch: 9.0.5 - ignore-walk@7.0.0: - dependencies: - minimatch: 9.0.5 - ignore@5.3.2: {} + ignore@7.0.3: {} + import-fresh@3.3.0: dependencies: parent-module: 1.0.1 @@ -8075,8 +7837,6 @@ snapshots: ini@4.1.3: {} - ini@5.0.0: {} - internal-slot@1.0.7: dependencies: es-errors: 1.3.0 @@ -8131,7 +7891,7 @@ snapshots: dependencies: has-tostringtag: 1.0.2 - is-docker@2.2.1: {} + is-docker@3.0.0: {} is-extglob@2.1.1: {} @@ -8141,6 +7901,10 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-inside-container@1.0.0: + dependencies: + is-docker: 3.0.0 + is-interactive@2.0.0: {} is-lambda@1.0.1: {} @@ -8203,9 +7967,9 @@ snapshots: call-bind: 1.0.7 get-intrinsic: 1.2.4 - is-wsl@2.2.0: + is-wsl@3.1.0: dependencies: - is-docker: 2.2.1 + is-inside-container: 1.0.0 isarray@1.0.0: {} @@ -8240,7 +8004,7 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 - jackspeak@4.0.2: + jackspeak@4.1.0: dependencies: '@isaacs/cliui': 8.0.2 @@ -8262,16 +8026,12 @@ snapshots: json-parse-even-better-errors@3.0.2: {} - json-parse-even-better-errors@4.0.0: {} - json-schema-traverse@0.4.1: {} json-schema-traverse@1.0.0: {} json-stable-stringify-without-jsonify@1.0.1: {} - json-stringify-nice@1.1.4: {} - json5@1.0.2: dependencies: minimist: 1.2.8 @@ -8299,10 +8059,6 @@ snapshots: ms: 2.1.3 semver: 7.6.3 - just-diff-apply@5.5.0: {} - - just-diff@6.0.2: {} - jwa@1.4.1: dependencies: buffer-equal-constant-time: 1.0.1 @@ -8428,24 +8184,10 @@ snapshots: transitivePeerDependencies: - supports-color - make-fetch-happen@14.0.3: - dependencies: - '@npmcli/agent': 3.0.0 - cacache: 19.0.1 - http-cache-semantics: 4.1.1 - minipass: 7.1.2 - minipass-fetch: 4.0.1 - minipass-flush: 1.0.5 - minipass-pipeline: 1.2.4 - negotiator: 1.0.0 - proc-log: 5.0.0 - promise-retry: 2.0.1 - ssri: 12.0.0 - transitivePeerDependencies: - - supports-color - marked@15.0.7: {} + math-intrinsics@1.1.0: {} + mdurl@1.0.1: {} media-typer@0.3.0: {} @@ -8503,14 +8245,6 @@ snapshots: optionalDependencies: encoding: 0.1.13 - minipass-fetch@4.0.1: - dependencies: - minipass: 7.1.2 - minipass-sized: 1.0.3 - minizlib: 3.0.1 - optionalDependencies: - encoding: 0.1.13 - minipass-flush@1.0.5: dependencies: minipass: 3.3.6 @@ -8583,8 +8317,6 @@ snapshots: negotiator@0.6.3: {} - negotiator@1.0.0: {} - node-domexception@1.0.0: {} node-fetch@2.7.0(encoding@0.1.13): @@ -8614,31 +8346,12 @@ snapshots: transitivePeerDependencies: - supports-color - node-gyp@11.1.0: - dependencies: - env-paths: 2.2.1 - exponential-backoff: 3.1.1 - glob: 10.4.5 - graceful-fs: 4.2.11 - make-fetch-happen: 14.0.3 - nopt: 8.1.0 - proc-log: 5.0.0 - semver: 7.6.3 - tar: 7.4.3 - which: 5.0.0 - transitivePeerDependencies: - - supports-color - node-releases@2.0.18: {} nopt@7.2.1: dependencies: abbrev: 2.0.0 - nopt@8.1.0: - dependencies: - abbrev: 3.0.0 - normalize-package-data@2.5.0: dependencies: hosted-git-info: 2.8.9 @@ -8656,22 +8369,12 @@ snapshots: dependencies: npm-normalize-package-bin: 3.0.1 - npm-bundled@4.0.0: - dependencies: - npm-normalize-package-bin: 4.0.0 - npm-install-checks@6.3.0: dependencies: semver: 7.6.3 - npm-install-checks@7.1.1: - dependencies: - semver: 7.6.3 - npm-normalize-package-bin@3.0.1: {} - npm-normalize-package-bin@4.0.0: {} - npm-package-arg@11.0.3: dependencies: hosted-git-info: 7.0.2 @@ -8679,28 +8382,10 @@ snapshots: semver: 7.6.3 validate-npm-package-name: 5.0.1 - npm-package-arg@12.0.2: - dependencies: - hosted-git-info: 8.0.2 - proc-log: 5.0.0 - semver: 7.6.3 - validate-npm-package-name: 6.0.0 - npm-packlist@8.0.2: dependencies: ignore-walk: 6.0.5 - npm-packlist@9.0.0: - dependencies: - ignore-walk: 7.0.0 - - npm-pick-manifest@10.0.0: - dependencies: - npm-install-checks: 7.1.1 - npm-normalize-package-bin: 4.0.0 - npm-package-arg: 12.0.2 - semver: 7.6.3 - npm-pick-manifest@9.1.0: dependencies: npm-install-checks: 6.3.0 @@ -8721,19 +8406,6 @@ snapshots: transitivePeerDependencies: - supports-color - npm-registry-fetch@18.0.2: - dependencies: - '@npmcli/redact': 3.1.1 - jsonparse: 1.3.1 - make-fetch-happen: 14.0.3 - minipass: 7.1.2 - minipass-fetch: 4.0.1 - minizlib: 3.0.1 - npm-package-arg: 12.0.2 - proc-log: 5.0.0 - transitivePeerDependencies: - - supports-color - object-assign@4.1.1: {} object-inspect@1.13.2: {} @@ -8806,11 +8478,12 @@ snapshots: dependencies: mimic-fn: 2.1.0 - open@8.4.2: + open@10.1.0: dependencies: - define-lazy-prop: 2.0.0 - is-docker: 2.2.1 - is-wsl: 2.2.0 + default-browser: 5.2.1 + define-lazy-prop: 3.0.0 + is-inside-container: 1.0.0 + is-wsl: 3.1.0 optionator@0.9.4: dependencies: @@ -8863,8 +8536,6 @@ snapshots: dependencies: aggregate-error: 3.1.0 - p-map@7.0.3: {} - p-try@2.2.0: {} package-json-from-dist@1.0.0: {} @@ -8892,50 +8563,6 @@ snapshots: - bluebird - supports-color - pacote@19.0.1: - dependencies: - '@npmcli/git': 6.0.3 - '@npmcli/installed-package-contents': 3.0.0 - '@npmcli/package-json': 6.1.1 - '@npmcli/promise-spawn': 8.0.2 - '@npmcli/run-script': 9.0.2 - cacache: 19.0.1 - fs-minipass: 3.0.3 - minipass: 7.1.2 - npm-package-arg: 12.0.2 - npm-packlist: 9.0.0 - npm-pick-manifest: 10.0.0 - npm-registry-fetch: 18.0.2 - proc-log: 5.0.0 - promise-retry: 2.0.1 - sigstore: 3.1.0 - ssri: 12.0.0 - tar: 6.2.1 - transitivePeerDependencies: - - supports-color - - pacote@20.0.0: - dependencies: - '@npmcli/git': 6.0.3 - '@npmcli/installed-package-contents': 3.0.0 - '@npmcli/package-json': 6.1.1 - '@npmcli/promise-spawn': 8.0.2 - '@npmcli/run-script': 9.0.2 - cacache: 19.0.1 - fs-minipass: 3.0.3 - minipass: 7.1.2 - npm-package-arg: 12.0.2 - npm-packlist: 9.0.0 - npm-pick-manifest: 10.0.0 - npm-registry-fetch: 18.0.2 - proc-log: 5.0.0 - promise-retry: 2.0.1 - sigstore: 3.1.0 - ssri: 12.0.0 - tar: 6.2.1 - transitivePeerDependencies: - - supports-color - parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -8944,12 +8571,6 @@ snapshots: dependencies: callsites: 3.1.0 - parse-conflict-json@4.0.0: - dependencies: - json-parse-even-better-errors: 4.0.0 - just-diff: 6.0.2 - just-diff-apply: 5.5.0 - parse-json@5.2.0: dependencies: '@babel/code-frame': 7.24.7 @@ -8987,6 +8608,8 @@ snapshots: path-type@5.0.0: {} + path-type@6.0.0: {} + pathe@2.0.3: {} pathval@2.0.0: {} @@ -9001,35 +8624,22 @@ snapshots: possible-typed-array-names@1.0.0: {} - postcss-selector-parser@6.1.2: - dependencies: - cssesc: 3.0.0 - util-deprecate: 1.0.2 - postcss@8.4.47: dependencies: nanoid: 3.3.7 - picocolors: 1.1.0 + picocolors: 1.1.1 source-map-js: 1.2.1 prelude-ls@1.2.1: {} prettier@3.3.3: {} - prettier@3.4.2: {} + prettier@3.5.3: {} proc-log@4.2.0: {} - proc-log@5.0.0: {} - process-nextick-args@2.0.1: {} - proggy@3.0.0: {} - - promise-all-reject-late@1.0.1: {} - - promise-call-limit@3.0.2: {} - promise-inflight@1.0.1: {} promise-retry@2.0.1: @@ -9075,13 +8685,6 @@ snapshots: iconv-lite: 0.4.24 unpipe: 1.0.0 - read-cmd-shim@5.0.0: {} - - read-package-json-fast@4.0.0: - dependencies: - json-parse-even-better-errors: 4.0.0 - npm-normalize-package-bin: 4.0.0 - read-pkg-up@7.0.1: dependencies: find-up: 4.1.0 @@ -9191,6 +8794,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.22.4 fsevents: 2.3.3 + run-applescript@7.0.0: {} + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -9224,6 +8829,8 @@ snapshots: semver@7.6.3: {} + semver@7.7.1: {} + send@0.19.0: dependencies: debug: 2.6.9 @@ -9299,17 +8906,6 @@ snapshots: transitivePeerDependencies: - supports-color - sigstore@3.1.0: - dependencies: - '@sigstore/bundle': 3.1.0 - '@sigstore/core': 2.0.0 - '@sigstore/protobuf-specs': 0.4.0 - '@sigstore/sign': 3.1.0 - '@sigstore/tuf': 3.1.0 - '@sigstore/verify': 2.1.0 - transitivePeerDependencies: - - supports-color - simple-swizzle@0.2.2: dependencies: is-arrayish: 0.3.2 @@ -9323,7 +8919,7 @@ snapshots: socks-proxy-agent@8.0.4: dependencies: agent-base: 7.1.1 - debug: 4.3.7 + debug: 4.4.0 socks: 2.8.3 transitivePeerDependencies: - supports-color @@ -9362,10 +8958,6 @@ snapshots: dependencies: minipass: 7.1.2 - ssri@12.0.0: - dependencies: - minipass: 7.1.2 - stack-trace@0.0.10: {} stackback@0.0.2: {} @@ -9544,8 +9136,6 @@ snapshots: tr46@0.0.3: {} - treeverse@3.0.0: {} - triple-beam@1.4.1: {} ts-api-utils@1.3.0(typescript@5.6.2): @@ -9577,19 +9167,11 @@ snapshots: tuf-js@2.2.1: dependencies: '@tufjs/models': 2.0.1 - debug: 4.3.7 + debug: 4.4.0 make-fetch-happen: 13.0.1 transitivePeerDependencies: - supports-color - tuf-js@3.0.1: - dependencies: - '@tufjs/models': 3.0.1 - debug: 4.3.7 - make-fetch-happen: 14.0.3 - transitivePeerDependencies: - - supports-color - tunnel@0.0.6: {} type-check@0.4.0: @@ -9693,22 +9275,16 @@ snapshots: unicorn-magic@0.1.0: {} + unicorn-magic@0.3.0: {} + unique-filename@3.0.0: dependencies: unique-slug: 4.0.0 - unique-filename@4.0.0: - dependencies: - unique-slug: 5.0.0 - unique-slug@4.0.0: dependencies: imurmurhash: 0.1.4 - unique-slug@5.0.0: - dependencies: - imurmurhash: 0.1.4 - unique-string@3.0.0: dependencies: crypto-random-string: 4.0.0 @@ -9727,7 +9303,7 @@ snapshots: dependencies: browserslist: 4.24.0 escalade: 3.2.0 - picocolors: 1.1.0 + picocolors: 1.1.1 uri-js@4.4.1: dependencies: @@ -9752,8 +9328,6 @@ snapshots: validate-npm-package-name@5.0.1: {} - validate-npm-package-name@6.0.0: {} - vary@1.1.2: {} vite-node@3.0.8(@types/node@22.5.5): @@ -9835,8 +9409,6 @@ snapshots: vscode-uri@3.1.0: {} - walk-up-path@3.0.1: {} - web-streams-polyfill@3.3.3: {} webidl-conversions@3.0.1: {} @@ -9877,10 +9449,6 @@ snapshots: dependencies: isexe: 3.1.1 - which@5.0.0: - dependencies: - isexe: 3.1.1 - why-is-node-running@2.3.0: dependencies: siginfo: 2.0.0 @@ -9955,11 +9523,6 @@ snapshots: signal-exit: 3.0.7 typedarray-to-buffer: 3.1.5 - write-file-atomic@6.0.0: - dependencies: - imurmurhash: 0.1.4 - signal-exit: 4.1.0 - ws@8.18.1: {} xdg-basedir@5.1.0: {} From 6ea074bbd78b951964ad4520b1e0ff53286cf3f0 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 19 Mar 2025 03:02:27 +0000 Subject: [PATCH 2/9] Regenerate for typespec-python (2025-03-19 03:02:27) --- .../apiview-properties.json | 3 +- ...est_usage_model_in_operation_operations.py | 12 + ...age_model_in_operation_operations_async.py | 12 + .../core/usage/aio/operations/_operations.py | 61 + .../core/usage/models/_models.py | 13 +- .../core/usage/operations/_operations.py | 77 + .../core/scalar/aio/operations/_operations.py | 6 +- .../core/scalar/operations/_operations.py | 8 +- .../azure-encode-duration/CHANGELOG.md | 5 + .../generated/azure-encode-duration/LICENSE | 21 + .../azure-encode-duration/MANIFEST.in | 8 + .../generated/azure-encode-duration/README.md | 45 + .../apiview-properties.json | 7 + .../dev_requirements.txt | 3 + .../generated_tests/conftest.py | 35 + .../generated_tests/test_duration.py | 24 + .../generated_tests/test_duration_async.py | 25 + .../generated_tests/testpreparer.py | 26 + .../generated_tests/testpreparer_async.py | 20 + .../generated/azure-encode-duration/setup.py | 72 + .../azure-encode-duration/specs/__init__.py | 1 + .../specs/azure/__init__.py | 1 + .../specs/azure/encode/__init__.py | 1 + .../specs/azure/encode/duration/__init__.py | 32 + .../specs/azure/encode/duration/_client.py | 91 + .../azure/encode/duration/_configuration.py | 42 + .../azure/encode/duration/_model_base.py | 1235 ++++++++++ .../encode/duration/_operations/__init__.py | 25 + .../duration/_operations/_operations.py | 159 ++ .../encode/duration/_operations/_patch.py | 20 + .../specs/azure/encode/duration/_patch.py | 20 + .../azure/encode/duration/_serialization.py | 2050 +++++++++++++++++ .../specs/azure/encode/duration/_vendor.py | 25 + .../specs/azure/encode/duration/_version.py | 9 + .../azure/encode/duration/aio/__init__.py | 29 + .../azure/encode/duration/aio/_client.py | 93 + .../encode/duration/aio/_configuration.py | 42 + .../duration/aio/_operations/__init__.py | 25 + .../duration/aio/_operations/_operations.py | 143 ++ .../encode/duration/aio/_operations/_patch.py | 20 + .../specs/azure/encode/duration/aio/_patch.py | 20 + .../azure/encode/duration/aio/_vendor.py | 25 + .../azure/encode/duration/models/__init__.py | 27 + .../azure/encode/duration/models/_models.py | 42 + .../azure/encode/duration/models/_patch.py | 20 + .../specs/azure/encode/duration/py.typed | 1 + .../apiview-properties.json | 14 +- .../commonproperties/_client.py | 5 +- .../commonproperties/aio/_client.py | 5 +- .../aio/operations/__init__.py | 2 + .../aio/operations/_operations.py | 255 ++ .../commonproperties/models/__init__.py | 12 + .../commonproperties/models/_models.py | 304 ++- .../commonproperties/operations/__init__.py | 2 + .../operations/_operations.py | 312 +++ ...test_common_properties_error_operations.py | 57 + ...ommon_properties_error_operations_async.py | 58 + .../client-namespace/apiview-properties.json | 4 +- .../generated_tests/conftest.py | 26 +- .../generated_tests/testpreparer.py | 20 +- .../generated_tests/testpreparer_async.py | 12 +- .../naming/aio/operations/_operations.py | 8 +- .../client/naming/operations/_operations.py | 8 +- .../bytes/aio/operations/_operations.py | 57 +- .../encode/bytes/operations/_operations.py | 63 +- .../apiview-properties.json | 1 - ...test_collection_format_query_operations.py | 11 - ...ollection_format_query_operations_async.py | 11 - .../aio/operations/_operations.py | 48 - .../operations/_operations.py | 59 - .../_operations/_operations.py | 8 +- .../aio/_operations/_operations.py | 4 +- .../serialization/encodedname/json/_client.py | 2 +- .../encodedname/json/aio/_client.py | 2 +- .../generated/streaming-jsonl/CHANGELOG.md | 5 + .../azure/generated/streaming-jsonl/LICENSE | 21 + .../generated/streaming-jsonl/MANIFEST.in | 6 + .../azure/generated/streaming-jsonl/README.md | 45 + .../streaming-jsonl/apiview-properties.json | 7 + .../streaming-jsonl/dev_requirements.txt | 3 + .../generated_tests/conftest.py | 35 + .../test_jsonl_basic_operations.py} | 25 +- .../test_jsonl_basic_operations_async.py | 35 + .../generated_tests/testpreparer.py | 24 + .../generated_tests/testpreparer_async.py | 20 + .../azure/generated/streaming-jsonl/setup.py | 70 + .../streaming-jsonl/streaming/__init__.py | 1 + .../streaming/jsonl/__init__.py | 32 + .../streaming/jsonl/_client.py | 94 + .../streaming/jsonl/_configuration.py | 42 + .../streaming/jsonl/_model_base.py | 1235 ++++++++++ .../streaming-jsonl/streaming/jsonl/_patch.py | 20 + .../streaming/jsonl/_serialization.py | 2050 +++++++++++++++++ .../streaming/jsonl/_version.py | 9 + .../streaming/jsonl/aio/__init__.py | 29 + .../streaming/jsonl/aio/_client.py | 96 + .../streaming/jsonl/aio/_configuration.py | 42 + .../streaming/jsonl/aio/_patch.py | 20 + .../jsonl/aio/operations/__init__.py | 25 + .../jsonl/aio/operations/_operations.py | 161 ++ .../streaming/jsonl/aio/operations/_patch.py | 20 + .../streaming/jsonl/operations/__init__.py | 25 + .../streaming/jsonl/operations/_operations.py | 190 ++ .../streaming/jsonl/operations/_patch.py | 20 + .../streaming-jsonl/streaming/jsonl/py.typed | 1 + .../extensible/aio/operations/_operations.py | 15 +- .../enum/extensible/operations/_operations.py | 19 +- .../apiview-properties.json | 3 - ...rd_discriminated_union_operations_async.py | 34 - .../property/additionalproperties/_client.py | 7 - .../additionalproperties/aio/_client.py | 7 - .../aio/operations/__init__.py | 2 - .../aio/operations/_operations.py | 181 -- .../additionalproperties/models/__init__.py | 2 - .../additionalproperties/models/_models.py | 28 - .../operations/__init__.py | 2 - .../operations/_operations.py | 209 -- .../scalar/aio/operations/_operations.py | 32 +- .../typetest/scalar/operations/_operations.py | 40 +- .../_operations/_operations.py | 11 +- .../aio/_operations/_operations.py | 9 +- .../requestbody/aio/operations/_operations.py | 14 +- .../requestbody/operations/_operations.py | 14 +- .../aio/operations/_operations.py | 46 +- .../responsebody/operations/_operations.py | 52 +- .../query/aio/operations/_operations.py | 45 - .../query/operations/_operations.py | 56 - .../_operations/_operations.py | 8 +- .../aio/_operations/_operations.py | 4 +- .../serialization/encodedname/json/_client.py | 2 +- .../encodedname/json/aio/_client.py | 2 +- .../generated/streaming-jsonl/CHANGELOG.md | 5 + .../generated/streaming-jsonl/LICENSE | 21 + .../generated/streaming-jsonl/MANIFEST.in | 6 + .../generated/streaming-jsonl/README.md | 0 .../generated/streaming-jsonl/setup.py | 67 + .../streaming-jsonl/streaming/__init__.py | 1 + .../streaming/jsonl/__init__.py | 32 + .../streaming/jsonl/_client.py | 87 + .../streaming/jsonl/_configuration.py | 39 + .../streaming/jsonl/_model_base.py | 1235 ++++++++++ .../streaming-jsonl/streaming/jsonl/_patch.py | 20 + .../streaming/jsonl/_serialization.py | 2050 +++++++++++++++++ .../streaming/jsonl/_version.py | 9 + .../streaming/jsonl/aio/__init__.py | 29 + .../streaming/jsonl/aio/_client.py | 89 + .../streaming/jsonl/aio/_configuration.py | 39 + .../streaming/jsonl/aio/_patch.py | 20 + .../streaming/jsonl/basic/__init__.py | 1 + .../streaming/jsonl/basic/aio/__init__.py | 1 + .../jsonl/basic/aio/operations/__init__.py | 25 + .../jsonl/basic/aio/operations/_operations.py | 154 ++ .../jsonl/basic/aio/operations/_patch.py | 20 + .../jsonl/basic/operations/__init__.py | 25 + .../jsonl/basic/operations/_operations.py | 183 ++ .../jsonl/basic/operations/_patch.py | 20 + .../streaming-jsonl/streaming/jsonl/py.typed | 1 + .../extensible/aio/operations/_operations.py | 15 +- .../enum/extensible/operations/_operations.py | 19 +- .../property/additionalproperties/_client.py | 7 - .../additionalproperties/aio/_client.py | 7 - .../aio/operations/__init__.py | 2 - .../aio/operations/_operations.py | 175 -- .../additionalproperties/models/__init__.py | 2 - .../additionalproperties/models/_models.py | 28 - .../operations/__init__.py | 2 - .../operations/_operations.py | 203 -- .../scalar/aio/operations/_operations.py | 32 +- .../typetest/scalar/operations/_operations.py | 40 +- .../_operations/_operations.py | 11 +- .../aio/_operations/_operations.py | 9 +- 171 files changed, 14507 insertions(+), 1527 deletions(-) create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/README.md create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/conftest.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/setup.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_version.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_models.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/py.typed create mode 100644 packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations_async.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/README.md create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/conftest.py rename packages/typespec-python/test/azure/generated/{typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations.py => streaming-jsonl/generated_tests/test_jsonl_basic_operations.py} (51%) create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations_async.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/setup.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_client.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_version.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/py.typed delete mode 100644 packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations_async.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/CHANGELOG.md create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/LICENSE create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/MANIFEST.in create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/README.md create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/setup.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_client.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_configuration.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_model_base.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_serialization.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_version.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_client.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_operations.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_operations.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/py.typed diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/apiview-properties.json index 6b76d573f63..8b6ce4d479c 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/apiview-properties.json @@ -8,6 +8,7 @@ "specs.azure.clientgenerator.core.usage.models.RoundTripModel": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.RoundTripModel", "specs.azure.clientgenerator.core.usage.UsageClient.model_in_operation.input_to_input_output": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.inputToInputOutput", "specs.azure.clientgenerator.core.usage.UsageClient.model_in_operation.output_to_input_output": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.outputToInputOutput", - "specs.azure.clientgenerator.core.usage.UsageClient.model_in_operation.model_in_read_only_property": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty" + "specs.azure.clientgenerator.core.usage.UsageClient.model_in_operation.model_in_read_only_property": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty", + "specs.azure.clientgenerator.core.usage.UsageClient.model_in_operation.orphan_model_serializable": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.orphanModelSerializable" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations.py index 1594a7225fd..4cfbc8e6cbb 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations.py @@ -42,3 +42,15 @@ def test_model_in_operation_model_in_read_only_property(self, usage_endpoint): # please add some check logic here by yourself # ... + + @UsagePreparer() + @recorded_by_proxy + def test_model_in_operation_orphan_model_serializable(self, usage_endpoint): + client = self.create_client(endpoint=usage_endpoint) + response = client.model_in_operation.orphan_model_serializable( + body={}, + content_type="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations_async.py index c0b04a06e4d..3ab4fce35a8 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations_async.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/generated_tests/test_usage_model_in_operation_operations_async.py @@ -43,3 +43,15 @@ async def test_model_in_operation_model_in_read_only_property(self, usage_endpoi # please add some check logic here by yourself # ... + + @UsagePreparer() + @recorded_by_proxy_async + async def test_model_in_operation_orphan_model_serializable(self, usage_endpoint): + client = self.create_async_client(endpoint=usage_endpoint) + response = await client.model_in_operation.orphan_model_serializable( + body={}, + content_type="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/aio/operations/_operations.py index cc2a46337ce..1d8bd8e2cef 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/aio/operations/_operations.py @@ -32,6 +32,7 @@ from ...operations._operations import ( build_model_in_operation_input_to_input_output_request, build_model_in_operation_model_in_read_only_property_request, + build_model_in_operation_orphan_model_serializable_request, build_model_in_operation_output_to_input_output_request, ) from .._configuration import UsageClientConfiguration @@ -435,3 +436,63 @@ async def model_in_read_only_property( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + @distributed_trace_async + async def orphan_model_serializable(self, body: Any, **kwargs: Any) -> None: + """Serialize the 'OrphanModel' as request body. + + Expected body parameter: + + .. code-block:: json + + { + "name": "name", + "desc": "desc" + }. + + :param body: Required. + :type body: any + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_model_in_operation_orphan_model_serializable_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py index cbc58bcb8c7..9126293a8fc 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py @@ -48,18 +48,23 @@ class OrphanModel(_model_base.Model): """Not used anywhere, but access is override to public so still need to be generated and exported with serialization. - :ivar name: Required. - :vartype name: str + :ivar model_name: Required. + :vartype model_name: str + :ivar description: Required. + :vartype description: str """ - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + model_name: str = rest_field(name="modelName", visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + description: str = rest_field(name="desc", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload def __init__( self, *, - name: str, + model_name: str, + description: str, ) -> None: ... @overload diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/operations/_operations.py index 1beec9b9fd7..40ec4a8b16d 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/operations/_operations.py @@ -94,6 +94,21 @@ def build_model_in_operation_model_in_read_only_property_request( # pylint: dis return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) +def build_model_in_operation_orphan_model_serializable_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: str = kwargs.pop("content_type") + # Construct URL + _url = "/azure/client-generator-core/usage/orphanModelSerializable" + + # Construct headers + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + class ModelInOperationOperations: """ .. warning:: @@ -484,3 +499,65 @@ def model_in_read_only_property( return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + @distributed_trace + def orphan_model_serializable( # pylint: disable=inconsistent-return-statements + self, body: Any, **kwargs: Any + ) -> None: + """Serialize the 'OrphanModel' as request body. + + Expected body parameter: + + .. code-block:: json + + { + "name": "name", + "desc": "desc" + }. + + :param body: Required. + :type body: any + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_model_in_operation_orphan_model_serializable_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py index 9042acaf298..d24b2bddf28 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py @@ -113,7 +113,7 @@ async def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -141,10 +141,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_azure_location_scalar_put_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py index 9ccb4a4c275..a5136bcb1f6 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py @@ -46,7 +46,7 @@ def build_azure_location_scalar_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/azure/core/scalar/azureLocation" @@ -181,7 +181,7 @@ def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -209,10 +209,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_azure_location_scalar_put_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-encode-duration/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/LICENSE b/packages/typespec-python/test/azure/generated/azure-encode-duration/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-encode-duration/MANIFEST.in new file mode 100644 index 00000000000..d3512263cc7 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/MANIFEST.in @@ -0,0 +1,8 @@ +include *.md +include LICENSE +include specs/azure/encode/duration/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include specs/__init__.py +include specs/azure/__init__.py +include specs/azure/encode/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/README.md b/packages/typespec-python/test/azure/generated/azure-encode-duration/README.md new file mode 100644 index 00000000000..59b9ef07693 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/README.md @@ -0,0 +1,45 @@ + + +# Specs Azure Encode Duration client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install specs-azure-encode-duration +``` + +#### Prequisites + +- Python 3.8 or later is required to use this package. +- You need an [Azure subscription][azure_sub] to use this package. +- An existing Specs Azure Encode Duration instance. + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + + +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials +[azure_identity_pip]: https://pypi.org/project/azure-identity/ +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential +[pip]: https://pypi.org/project/pip/ +[azure_sub]: https://azure.microsoft.com/free/ + diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-encode-duration/apiview-properties.json new file mode 100644 index 00000000000..a6e6f7b11e1 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/apiview-properties.json @@ -0,0 +1,7 @@ +{ + "CrossLanguagePackageId": "_Specs_.Azure.Encode.Duration", + "CrossLanguageDefinitionId": { + "specs.azure.encode.duration.models.DurationModel": "_Specs_.Azure.Encode.Duration.DurationModel", + "specs.azure.encode.duration.DurationClient.duration_constant": "_Specs_.Azure.Encode.Duration.durationConstant" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-encode-duration/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/conftest.py new file mode 100644 index 00000000000..7c8e921ac05 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + duration_subscription_id = os.environ.get("DURATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + duration_tenant_id = os.environ.get("DURATION_TENANT_ID", "00000000-0000-0000-0000-000000000000") + duration_client_id = os.environ.get("DURATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + duration_client_secret = os.environ.get("DURATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=duration_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=duration_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=duration_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=duration_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration.py new file mode 100644 index 00000000000..e5e84e26ce1 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import DurationClientTestBase, DurationPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDuration(DurationClientTestBase): + @DurationPreparer() + @recorded_by_proxy + def test_duration_constant(self, duration_endpoint): + client = self.create_client(endpoint=duration_endpoint) + response = client.duration_constant( + body={"input": "1 day, 0:00:00"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration_async.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration_async.py new file mode 100644 index 00000000000..cb3d9bf4047 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/test_duration_async.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import DurationPreparer +from testpreparer_async import DurationClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDurationAsync(DurationClientTestBaseAsync): + @DurationPreparer() + @recorded_by_proxy_async + async def test_duration_constant(self, duration_endpoint): + client = self.create_async_client(endpoint=duration_endpoint) + response = await client.duration_constant( + body={"input": "1 day, 0:00:00"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer.py new file mode 100644 index 00000000000..5182f3adebc --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools +from specs.azure.encode.duration import DurationClient + + +class DurationClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(DurationClient) + return self.create_client_from_credential( + DurationClient, + credential=credential, + endpoint=endpoint, + ) + + +DurationPreparer = functools.partial( + PowerShellPreparer, "duration", duration_endpoint="https://fake_duration_endpoint.com" +) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..8d38c5e2b40 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase +from specs.azure.encode.duration.aio import DurationClient + + +class DurationClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(DurationClient, is_async=True) + return self.create_client_from_credential( + DurationClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/setup.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/setup.py new file mode 100644 index 00000000000..2d6e5e715ff --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/setup.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "specs-azure-encode-duration" +PACKAGE_PPRINT_NAME = "Specs Azure Encode Duration" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "specs", + "specs.azure", + "specs.azure.encode", + ] + ), + include_package_data=True, + package_data={ + "specs.azure.encode.duration": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/__init__.py new file mode 100644 index 00000000000..c0610d47384 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/__init__.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import DurationClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_client.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_client.py new file mode 100644 index 00000000000..686a4b7ec5e --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_client.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import DurationClientConfiguration +from ._operations import DurationClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class DurationClient(DurationClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for azure related encode decorator. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = DurationClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_configuration.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_configuration.py new file mode 100644 index 00000000000..29089b62ca4 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_configuration.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class DurationClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DurationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "specs-azure-encode-duration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_model_base.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/__init__.py new file mode 100644 index 00000000000..84eb3d779ef --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import DurationClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DurationClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_operations.py new file mode 100644 index 00000000000..c373649119e --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_operations.py @@ -0,0 +1,159 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import json +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .. import models as _models +from .._model_base import SdkJSONEncoder +from .._serialization import Serializer +from .._vendor import DurationClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_duration_duration_constant_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + # Construct URL + _url = "/azure/encode/duration/duration-constant" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + +class DurationClientOperationsMixin(DurationClientMixinABC): + + @overload + def duration_constant( + self, body: _models.DurationModel, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: ~specs.azure.encode.duration.models.DurationModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def duration_constant(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def duration_constant(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def duration_constant( # pylint: disable=inconsistent-return-statements + self, body: Union[_models.DurationModel, JSON, IO[bytes]], **kwargs: Any + ) -> None: + """Test duration with azure specific encoding. + + :param body: Is one of the following types: DurationModel, JSON, IO[bytes] Required. + :type body: ~specs.azure.encode.duration.models.DurationModel or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_duration_duration_constant_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_patch.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_serialization.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_serialization.py new file mode 100644 index 00000000000..7a0232de5dd --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_vendor.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_vendor.py new file mode 100644 index 00000000000..2e2565b9894 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import DurationClientConfiguration + +if TYPE_CHECKING: + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class DurationClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: DurationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_version.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/__init__.py new file mode 100644 index 00000000000..27b213da2f3 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import DurationClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_client.py new file mode 100644 index 00000000000..b9186aeb4a8 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_client.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import DurationClientConfiguration +from ._operations import DurationClientOperationsMixin + + +class DurationClient(DurationClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for azure related encode decorator. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = DurationClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_configuration.py new file mode 100644 index 00000000000..8c21dd16977 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_configuration.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class DurationClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DurationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "specs-azure-encode-duration/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/__init__.py new file mode 100644 index 00000000000..84eb3d779ef --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import DurationClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DurationClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_operations.py new file mode 100644 index 00000000000..0155ccd12b6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_operations.py @@ -0,0 +1,143 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import json +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ..._model_base import SdkJSONEncoder +from ..._operations._operations import build_duration_duration_constant_request +from .._vendor import DurationClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DurationClientOperationsMixin(DurationClientMixinABC): + + @overload + async def duration_constant( + self, body: _models.DurationModel, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: ~specs.azure.encode.duration.models.DurationModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def duration_constant(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def duration_constant( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Test duration with azure specific encoding. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def duration_constant(self, body: Union[_models.DurationModel, JSON, IO[bytes]], **kwargs: Any) -> None: + """Test duration with azure specific encoding. + + :param body: Is one of the following types: DurationModel, JSON, IO[bytes] Required. + :type body: ~specs.azure.encode.duration.models.DurationModel or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_duration_duration_constant_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_vendor.py new file mode 100644 index 00000000000..e4b6955d9a2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import DurationClientConfiguration + +if TYPE_CHECKING: + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class DurationClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: DurationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/__init__.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/__init__.py new file mode 100644 index 00000000000..e9df0d132b5 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/__init__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + DurationModel, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DurationModel", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_models.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_models.py new file mode 100644 index 00000000000..10672fccf8d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_models.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, overload + +from .. import _model_base +from .._model_base import rest_field + + +class DurationModel(_model_base.Model): + """DurationModel. + + :ivar input: Required. + :vartype input: ~datetime.timedelta + """ + + input: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + input: datetime.timedelta, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_patch.py b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/py.typed b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-encode-duration/specs/azure/encode/duration/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/apiview-properties.json index 438b8058e1b..b809f6ccd04 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/apiview-properties.json @@ -1,11 +1,17 @@ { "CrossLanguagePackageId": "Azure.ResourceManager.CommonProperties", "CrossLanguageDefinitionId": { + "azure.resourcemanager.commonproperties.models.ApiError": "Azure.ResourceManager.CommonProperties.ApiError", + "azure.resourcemanager.commonproperties.models.ApiErrorBase": "Azure.ResourceManager.CommonProperties.ApiErrorBase", + "azure.resourcemanager.commonproperties.models.CloudError": "Azure.ResourceManager.CommonProperties.CloudError", + "azure.resourcemanager.commonproperties.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.resourcemanager.commonproperties.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.resourcemanager.commonproperties.models.ConfidentialResource": "Azure.ResourceManager.CommonProperties.ConfidentialResource", + "azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties": "Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties", "azure.resourcemanager.commonproperties.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", "azure.resourcemanager.commonproperties.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", "azure.resourcemanager.commonproperties.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", - "azure.resourcemanager.commonproperties.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", - "azure.resourcemanager.commonproperties.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.resourcemanager.commonproperties.models.InnerError": "Azure.ResourceManager.CommonProperties.InnerError", "azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResource": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource", "azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties", "azure.resourcemanager.commonproperties.models.ManagedServiceIdentity": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", @@ -15,6 +21,8 @@ "azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", "azure.resourcemanager.commonproperties.CommonPropertiesClient.managed_identity.get": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get", "azure.resourcemanager.commonproperties.CommonPropertiesClient.managed_identity.create_with_system_assigned": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned", - "azure.resourcemanager.commonproperties.CommonPropertiesClient.managed_identity.update_with_user_assigned_and_system_assigned": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned" + "azure.resourcemanager.commonproperties.CommonPropertiesClient.managed_identity.update_with_user_assigned_and_system_assigned": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned", + "azure.resourcemanager.commonproperties.CommonPropertiesClient.error.get_for_predefined_error": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError", + "azure.resourcemanager.commonproperties.CommonPropertiesClient.error.create_for_user_defined_error": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_client.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_client.py index f23c2e26442..4c1b4338a2a 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_client.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_client.py @@ -17,7 +17,7 @@ from ._configuration import CommonPropertiesClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import ManagedIdentityOperations +from .operations import ErrorOperations, ManagedIdentityOperations if TYPE_CHECKING: from azure.core.credentials import TokenCredential @@ -29,6 +29,8 @@ class CommonPropertiesClient: :ivar managed_identity: ManagedIdentityOperations operations :vartype managed_identity: azure.resourcemanager.commonproperties.operations.ManagedIdentityOperations + :ivar error: ErrorOperations operations + :vartype error: azure.resourcemanager.commonproperties.operations.ErrorOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -78,6 +80,7 @@ def __init__( self.managed_identity = ManagedIdentityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.error = ErrorOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/_client.py index d9a0629c5d7..54116b5564e 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/_client.py @@ -17,7 +17,7 @@ from .._serialization import Deserializer, Serializer from ._configuration import CommonPropertiesClientConfiguration -from .operations import ManagedIdentityOperations +from .operations import ErrorOperations, ManagedIdentityOperations if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential @@ -29,6 +29,8 @@ class CommonPropertiesClient: :ivar managed_identity: ManagedIdentityOperations operations :vartype managed_identity: azure.resourcemanager.commonproperties.aio.operations.ManagedIdentityOperations + :ivar error: ErrorOperations operations + :vartype error: azure.resourcemanager.commonproperties.aio.operations.ErrorOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -78,6 +80,7 @@ def __init__( self.managed_identity = ManagedIdentityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.error = ErrorOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/__init__.py index cc207e17901..f406b6d443e 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/__init__.py @@ -13,6 +13,7 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import ManagedIdentityOperations # type: ignore +from ._operations import ErrorOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -20,6 +21,7 @@ __all__ = [ "ManagedIdentityOperations", + "ErrorOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py index 5f77a06da92..0784ca748f6 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py @@ -31,6 +31,8 @@ from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._serialization import Deserializer, Serializer from ...operations._operations import ( + build_error_create_for_user_defined_error_request, + build_error_get_for_predefined_error_request, build_managed_identity_create_with_system_assigned_request, build_managed_identity_get_request, build_managed_identity_update_with_user_assigned_and_system_assigned_request, @@ -473,3 +475,256 @@ async def update_with_user_assigned_and_system_assigned( # pylint: disable=name return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + +class ErrorOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.resourcemanager.commonproperties.aio.CommonPropertiesClient`'s + :attr:`error` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CommonPropertiesClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_for_predefined_error( + self, resource_group_name: str, confidential_resource_name: str, **kwargs: Any + ) -> _models.ConfidentialResource: + """Get a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfidentialResource] = kwargs.pop("cls", None) + + _request = build_error_get_for_predefined_error_request( + resource_group_name=resource_group_name, + confidential_resource_name=confidential_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConfidentialResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: _models.ConfidentialResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: Union[_models.ConfidentialResource, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Is one of the following types: + ConfidentialResource, JSON, IO[bytes] Required. + :type resource: ~azure.resourcemanager.commonproperties.models.ConfidentialResource or JSON or + IO[bytes] + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfidentialResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_error_create_for_user_defined_error_request( + resource_group_name=resource_group_name, + confidential_resource_name=confidential_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.CloudError, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConfidentialResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/__init__.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/__init__.py index 435644cabd0..3eff4d97094 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/__init__.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/__init__.py @@ -14,9 +14,15 @@ from ._models import ( # type: ignore + ApiError, + ApiErrorBase, + CloudError, + ConfidentialResource, + ConfidentialResourceProperties, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, + InnerError, ManagedIdentityTrackedResource, ManagedIdentityTrackedResourceProperties, ManagedServiceIdentity, @@ -35,9 +41,15 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ApiError", + "ApiErrorBase", + "CloudError", + "ConfidentialResource", + "ConfidentialResourceProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "InnerError", "ManagedIdentityTrackedResource", "ManagedIdentityTrackedResourceProperties", "ManagedServiceIdentity", diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py index 649ebe3f744..ce7e8c5cb2f 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py @@ -18,67 +18,109 @@ from .. import models as _models -class ErrorAdditionalInfo(_model_base.Model): - """The resource management error additional info. +class ApiError(_model_base.Model): + """Api error. - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any + :ivar details: The Api error details. + :vartype details: list[~azure.resourcemanager.commonproperties.models.ApiErrorBase] + :ivar innererror: The Api inner error. + :vartype innererror: ~azure.resourcemanager.commonproperties.models.InnerError + :ivar code: The error code. + :vartype code: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar message: The error message. + :vartype message: str """ - type: Optional[str] = rest_field(visibility=["read"]) - """The additional info type.""" - info: Optional[Any] = rest_field(visibility=["read"]) - """The additional info.""" + details: Optional[List["_models.ApiErrorBase"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Api error details.""" + innererror: Optional["_models.InnerError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Api inner error.""" + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error code.""" + target: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target of the particular error.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error message.""" + @overload + def __init__( + self, + *, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... -class ErrorDetail(_model_base.Model): - """The error detail. + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiErrorBase(_model_base.Model): + """Api error base. :ivar code: The error code. :vartype code: str + :ivar target: The target of the particular error. + :vartype target: str :ivar message: The error message. :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.resourcemanager.commonproperties.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.resourcemanager.commonproperties.models.ErrorAdditionalInfo] """ - code: Optional[str] = rest_field(visibility=["read"]) + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error code.""" - message: Optional[str] = rest_field(visibility=["read"]) + target: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target of the particular error.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error message.""" - target: Optional[str] = rest_field(visibility=["read"]) - """The error target.""" - details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) - """The error details.""" - additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( - name="additionalInfo", visibility=["read"] - ) - """The error additional info.""" + @overload + def __init__( + self, + *, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... -class ErrorResponse(_model_base.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ - :ivar error: The error object. - :vartype error: ~azure.resourcemanager.commonproperties.models.ErrorDetail + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CloudError(_model_base.Model): + """An error response. + + :ivar error: Api error. + :vartype error: ~azure.resourcemanager.commonproperties.models.ApiError """ - error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The error object.""" + error: Optional["_models.ApiError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Api error.""" @overload def __init__( self, *, - error: Optional["_models.ErrorDetail"] = None, + error: Optional["_models.ApiError"] = None, ) -> None: ... @overload @@ -165,6 +207,194 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ConfidentialResource(TrackedResource): + """Concrete tracked resource types can be created by aliasing this type using a specific property + type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.resourcemanager.commonproperties.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties + """ + + properties: Optional["_models.ConfidentialResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ConfidentialResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConfidentialResourceProperties(_model_base.Model): + """Confidential Resource Properties. + + :ivar provisioning_state: The status of the last operation. Required. + :vartype provisioning_state: str + :ivar username: Required. + :vartype username: str + """ + + provisioning_state: str = rest_field(name="provisioningState", visibility=["read"]) + """The status of the last operation. Required.""" + username: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + username: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_model_base.Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_model_base.Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.resourcemanager.commonproperties.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.resourcemanager.commonproperties.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_model_base.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. + + :ivar error: The error object. + :vartype error: ~azure.resourcemanager.commonproperties.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InnerError(_model_base.Model): + """Inner error details. + + :ivar exceptiontype: The exception type. + :vartype exceptiontype: str + :ivar errordetail: The internal error message or exception dump. + :vartype errordetail: str + """ + + exceptiontype: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The exception type.""" + errordetail: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The internal error message or exception dump.""" + + @overload + def __init__( + self, + *, + exceptiontype: Optional[str] = None, + errordetail: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ManagedIdentityTrackedResource(TrackedResource): """Concrete tracked resource types can be created by aliasing this type using a specific property type. diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/__init__.py index cc207e17901..f406b6d443e 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/__init__.py @@ -13,6 +13,7 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import ManagedIdentityOperations # type: ignore +from ._operations import ErrorOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -20,6 +21,7 @@ __all__ = [ "ManagedIdentityOperations", + "ErrorOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py index 000fd3beafc..2e32ebb6d62 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py @@ -141,6 +141,65 @@ def build_managed_identity_update_with_user_assigned_and_system_assigned_request return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) +def build_error_get_for_predefined_error_request( # pylint: disable=name-too-long + resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "confidentialResourceName": _SERIALIZER.url("confidential_resource_name", confidential_resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_error_create_for_user_defined_error_request( # pylint: disable=name-too-long + resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "confidentialResourceName": _SERIALIZER.url("confidential_resource_name", confidential_resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + class ManagedIdentityOperations: """ .. warning:: @@ -568,3 +627,256 @@ def update_with_user_assigned_and_system_assigned( # pylint: disable=name-too-l return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + +class ErrorOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.resourcemanager.commonproperties.CommonPropertiesClient`'s + :attr:`error` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CommonPropertiesClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_for_predefined_error( + self, resource_group_name: str, confidential_resource_name: str, **kwargs: Any + ) -> _models.ConfidentialResource: + """Get a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfidentialResource] = kwargs.pop("cls", None) + + _request = build_error_get_for_predefined_error_request( + resource_group_name=resource_group_name, + confidential_resource_name=confidential_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConfidentialResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: _models.ConfidentialResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_for_user_defined_error( + self, + resource_group_name: str, + confidential_resource_name: str, + resource: Union[_models.ConfidentialResource, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ConfidentialResource: + """Create a ConfidentialResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param confidential_resource_name: The name of the ConfidentialResource. Required. + :type confidential_resource_name: str + :param resource: Resource create parameters. Is one of the following types: + ConfidentialResource, JSON, IO[bytes] Required. + :type resource: ~azure.resourcemanager.commonproperties.models.ConfidentialResource or JSON or + IO[bytes] + :return: ConfidentialResource. The ConfidentialResource is compatible with MutableMapping + :rtype: ~azure.resourcemanager.commonproperties.models.ConfidentialResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfidentialResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_error_create_for_user_defined_error_request( + resource_group_name=resource_group_name, + confidential_resource_name=confidential_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.CloudError, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ConfidentialResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations.py new file mode 100644 index 00000000000..427f508b084 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.commonproperties import CommonPropertiesClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCommonPropertiesErrorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CommonPropertiesClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_error_get_for_predefined_error(self, resource_group): + response = self.client.error.get_for_predefined_error( + resource_group_name=resource_group.name, + confidential_resource_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_error_create_for_user_defined_error(self, resource_group): + response = self.client.error.create_for_user_defined_error( + resource_group_name=resource_group.name, + confidential_resource_name="str", + resource={ + "location": "str", + "id": "str", + "name": "str", + "properties": {"provisioningState": "str", "username": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations_async.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations_async.py new file mode 100644 index 00000000000..ceedb3682f1 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/generated_tests/test_common_properties_error_operations_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.commonproperties.aio import CommonPropertiesClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCommonPropertiesErrorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CommonPropertiesClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_error_get_for_predefined_error(self, resource_group): + response = await self.client.error.get_for_predefined_error( + resource_group_name=resource_group.name, + confidential_resource_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_error_create_for_user_defined_error(self, resource_group): + response = await self.client.error.create_for_user_defined_error( + resource_group_name=resource_group.name, + confidential_resource_name="str", + resource={ + "location": "str", + "id": "str", + "name": "str", + "properties": {"provisioningState": "str", "username": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/client-namespace/apiview-properties.json b/packages/typespec-python/test/azure/generated/client-namespace/apiview-properties.json index d033f24aafd..f2235386cb8 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/client-namespace/apiview-properties.json @@ -4,7 +4,7 @@ "client.clientnamespace.first.models.FirstClientResult": "Client.ClientNamespace.FirstModel.FirstClientResult", "client.clientnamespace.second.models.SecondClientResult": "Client.ClientNamespace.Second.Model.SecondClientResult", "client.clientnamespace.models.SecondClientEnumType": "Client.ClientNamespace.Second.Model.SecondClientEnumType", - "client.clientnamespace.ClientNamespaceSecondClient.get_second": "ClientNameSpaceClient.ClientNamespaceSecondClient.getSecond", - "client.clientnamespace.ClientNamespaceFirstClient.get_first": "ClientNameSpaceClient.ClientNamespaceFirstClient.getFirst" + "client.clientnamespace.ClientNamespaceFirstClient.get_first": "ClientNameSpaceClient.ClientNamespaceFirstClient.getFirst", + "client.clientnamespace.ClientNamespaceSecondClient.get_second": "ClientNameSpaceClient.ClientNamespaceSecondClient.getSecond" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/conftest.py index 2e36252b815..6b58c0a8856 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/conftest.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/conftest.py @@ -21,19 +21,6 @@ # For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - namespacesecond_subscription_id = os.environ.get( - "NAMESPACESECOND_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" - ) - namespacesecond_tenant_id = os.environ.get("NAMESPACESECOND_TENANT_ID", "00000000-0000-0000-0000-000000000000") - namespacesecond_client_id = os.environ.get("NAMESPACESECOND_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - namespacesecond_client_secret = os.environ.get( - "NAMESPACESECOND_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" - ) - add_general_regex_sanitizer(regex=namespacesecond_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=namespacesecond_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=namespacesecond_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=namespacesecond_client_secret, value="00000000-0000-0000-0000-000000000000") - namespacefirst_subscription_id = os.environ.get( "NAMESPACEFIRST_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" ) @@ -47,6 +34,19 @@ def add_sanitizers(test_proxy): add_general_regex_sanitizer(regex=namespacefirst_client_id, value="00000000-0000-0000-0000-000000000000") add_general_regex_sanitizer(regex=namespacefirst_client_secret, value="00000000-0000-0000-0000-000000000000") + namespacesecond_subscription_id = os.environ.get( + "NAMESPACESECOND_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + namespacesecond_tenant_id = os.environ.get("NAMESPACESECOND_TENANT_ID", "00000000-0000-0000-0000-000000000000") + namespacesecond_client_id = os.environ.get("NAMESPACESECOND_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + namespacesecond_client_secret = os.environ.get( + "NAMESPACESECOND_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=namespacesecond_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=namespacesecond_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=namespacesecond_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=namespacesecond_client_secret, value="00000000-0000-0000-0000-000000000000") + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer.py index ae0a5a9af2f..e8a57ef35a2 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer.py @@ -11,33 +11,33 @@ import functools -class ClientNamespaceSecondClientTestBase(AzureRecordedTestCase): +class ClientNamespaceFirstClientTestBase(AzureRecordedTestCase): def create_client(self, endpoint): - credential = self.get_credential(ClientNamespaceSecondClient) + credential = self.get_credential(ClientNamespaceFirstClient) return self.create_client_from_credential( - ClientNamespaceSecondClient, + ClientNamespaceFirstClient, credential=credential, endpoint=endpoint, ) -NamespaceSecondPreparer = functools.partial( - PowerShellPreparer, "namespacesecond", namespacesecond_endpoint="https://fake_namespacesecond_endpoint.com" +NamespaceFirstPreparer = functools.partial( + PowerShellPreparer, "namespacefirst", namespacefirst_endpoint="https://fake_namespacefirst_endpoint.com" ) -class ClientNamespaceFirstClientTestBase(AzureRecordedTestCase): +class ClientNamespaceSecondClientTestBase(AzureRecordedTestCase): def create_client(self, endpoint): - credential = self.get_credential(ClientNamespaceFirstClient) + credential = self.get_credential(ClientNamespaceSecondClient) return self.create_client_from_credential( - ClientNamespaceFirstClient, + ClientNamespaceSecondClient, credential=credential, endpoint=endpoint, ) -NamespaceFirstPreparer = functools.partial( - PowerShellPreparer, "namespacefirst", namespacefirst_endpoint="https://fake_namespacefirst_endpoint.com" +NamespaceSecondPreparer = functools.partial( + PowerShellPreparer, "namespacesecond", namespacesecond_endpoint="https://fake_namespacesecond_endpoint.com" ) diff --git a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer_async.py index 20a78dc28f9..e6496e014fc 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer_async.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/generated_tests/testpreparer_async.py @@ -10,23 +10,23 @@ from devtools_testutils import AzureRecordedTestCase -class ClientNamespaceSecondClientTestBaseAsync(AzureRecordedTestCase): +class ClientNamespaceFirstClientTestBaseAsync(AzureRecordedTestCase): def create_async_client(self, endpoint): - credential = self.get_credential(ClientNamespaceSecondClient, is_async=True) + credential = self.get_credential(ClientNamespaceFirstClient, is_async=True) return self.create_client_from_credential( - ClientNamespaceSecondClient, + ClientNamespaceFirstClient, credential=credential, endpoint=endpoint, ) -class ClientNamespaceFirstClientTestBaseAsync(AzureRecordedTestCase): +class ClientNamespaceSecondClientTestBaseAsync(AzureRecordedTestCase): def create_async_client(self, endpoint): - credential = self.get_credential(ClientNamespaceFirstClient, is_async=True) + credential = self.get_credential(ClientNamespaceSecondClient, is_async=True) return self.create_client_from_credential( - ClientNamespaceFirstClient, + ClientNamespaceSecondClient, credential=credential, endpoint=endpoint, ) diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py index feb60837ffe..e98f1e9273e 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py @@ -307,10 +307,10 @@ async def union_enum_name(self, body: Union[str, _models.ClientExtensibleEnum], _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_union_enum_union_enum_name_request( content_type=content_type, @@ -358,10 +358,10 @@ async def union_enum_member_name(self, body: Union[str, _models.ExtensibleEnum], _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_union_enum_union_enum_member_name_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py index 7b535881495..b233f965334 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py @@ -435,10 +435,10 @@ def union_enum_name( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_union_enum_union_enum_name_request( content_type=content_type, @@ -488,10 +488,10 @@ def union_enum_member_name( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_union_enum_union_enum_member_name_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py index 885bcdf486d..3776e4e7ec6 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py @@ -1010,10 +1010,10 @@ async def default(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_default_request( content_type=content_type, @@ -1163,10 +1163,10 @@ async def base64(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_base64_request( content_type=content_type, @@ -1214,10 +1214,10 @@ async def base64_url(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore + _content = value _request = build_request_body_base64_url_request( content_type=content_type, @@ -1263,11 +1263,11 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def default(self, **kwargs: Any) -> bytes: + async def default(self, **kwargs: Any) -> AsyncIterator[bytes]: """default. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1281,7 +1281,7 @@ async def default(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_default_request( headers=_headers, @@ -1292,7 +1292,7 @@ async def default(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1308,10 +1308,7 @@ async def default(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1431,11 +1428,11 @@ async def custom_content_type(self, **kwargs: Any) -> AsyncIterator[bytes]: return deserialized # type: ignore @distributed_trace_async - async def base64(self, **kwargs: Any) -> bytes: + async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: """base64. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1449,7 +1446,7 @@ async def base64(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -1460,7 +1457,7 @@ async def base64(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1476,10 +1473,7 @@ async def base64(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1487,11 +1481,11 @@ async def base64(self, **kwargs: Any) -> bytes: return deserialized # type: ignore @distributed_trace_async - async def base64_url(self, **kwargs: Any) -> bytes: + async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: """base64_url. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1505,7 +1499,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -1516,7 +1510,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1532,10 +1526,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64url") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py index e7563868849..24635c43d46 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py @@ -276,7 +276,7 @@ def build_request_body_base64_url_request(**kwargs: Any) -> HttpRequest: def build_response_body_default_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/octet-stream") # Construct URL _url = "/encode/bytes/body/response/default" @@ -318,7 +318,7 @@ def build_response_body_custom_content_type_request(**kwargs: Any) -> HttpReques def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/octet-stream") # Construct URL _url = "/encode/bytes/body/response/base64" @@ -332,7 +332,7 @@ def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: def build_response_body_base64_url_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/encode/bytes/body/response/base64url" @@ -1292,10 +1292,10 @@ def default(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_default_request( content_type=content_type, @@ -1447,10 +1447,10 @@ def base64(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incons _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_base64_request( content_type=content_type, @@ -1498,10 +1498,10 @@ def base64_url(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=in _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore + _content = value _request = build_request_body_base64_url_request( content_type=content_type, @@ -1547,11 +1547,11 @@ def __init__(self, *args, **kwargs): self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def default(self, **kwargs: Any) -> bytes: + def default(self, **kwargs: Any) -> Iterator[bytes]: """default. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1565,7 +1565,7 @@ def default(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_default_request( headers=_headers, @@ -1576,7 +1576,7 @@ def default(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1592,10 +1592,7 @@ def default(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1715,11 +1712,11 @@ def custom_content_type(self, **kwargs: Any) -> Iterator[bytes]: return deserialized # type: ignore @distributed_trace - def base64(self, **kwargs: Any) -> bytes: + def base64(self, **kwargs: Any) -> Iterator[bytes]: """base64. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1733,7 +1730,7 @@ def base64(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -1744,7 +1741,7 @@ def base64(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1760,10 +1757,7 @@ def base64(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1771,11 +1765,11 @@ def base64(self, **kwargs: Any) -> bytes: return deserialized # type: ignore @distributed_trace - def base64_url(self, **kwargs: Any) -> bytes: + def base64_url(self, **kwargs: Any) -> Iterator[bytes]: """base64_url. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1789,7 +1783,7 @@ def base64_url(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -1800,7 +1794,7 @@ def base64_url(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1816,10 +1810,7 @@ def base64_url(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64url") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/apiview-properties.json b/packages/typespec-python/test/azure/generated/parameters-collection-format/apiview-properties.json index ece56b4dae7..d9ae0ea1f0b 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/apiview-properties.json @@ -3,7 +3,6 @@ "CrossLanguageDefinitionId": { "parameters.collectionformat.CollectionFormatClient.query.multi": "Parameters.CollectionFormat.Query.multi", "parameters.collectionformat.CollectionFormatClient.query.ssv": "Parameters.CollectionFormat.Query.ssv", - "parameters.collectionformat.CollectionFormatClient.query.tsv": "Parameters.CollectionFormat.Query.tsv", "parameters.collectionformat.CollectionFormatClient.query.pipes": "Parameters.CollectionFormat.Query.pipes", "parameters.collectionformat.CollectionFormatClient.query.csv": "Parameters.CollectionFormat.Query.csv", "parameters.collectionformat.CollectionFormatClient.header.csv": "Parameters.CollectionFormat.Header.csv" diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations.py b/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations.py index 12397560740..498661d3112 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations.py +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations.py @@ -34,17 +34,6 @@ def test_query_ssv(self, collectionformat_endpoint): # please add some check logic here by yourself # ... - @CollectionFormatPreparer() - @recorded_by_proxy - def test_query_tsv(self, collectionformat_endpoint): - client = self.create_client(endpoint=collectionformat_endpoint) - response = client.query.tsv( - colors=["str"], - ) - - # please add some check logic here by yourself - # ... - @CollectionFormatPreparer() @recorded_by_proxy def test_query_pipes(self, collectionformat_endpoint): diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations_async.py b/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations_async.py index 4a73943c601..bffe393738b 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations_async.py +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/generated_tests/test_collection_format_query_operations_async.py @@ -35,17 +35,6 @@ async def test_query_ssv(self, collectionformat_endpoint): # please add some check logic here by yourself # ... - @CollectionFormatPreparer() - @recorded_by_proxy_async - async def test_query_tsv(self, collectionformat_endpoint): - client = self.create_async_client(endpoint=collectionformat_endpoint) - response = await client.query.tsv( - colors=["str"], - ) - - # please add some check logic here by yourself - # ... - @CollectionFormatPreparer() @recorded_by_proxy_async async def test_query_pipes(self, collectionformat_endpoint): diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/aio/operations/_operations.py index 892a6a4dacd..315a97a9bfb 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/aio/operations/_operations.py @@ -28,7 +28,6 @@ build_query_multi_request, build_query_pipes_request, build_query_ssv_request, - build_query_tsv_request, ) from .._configuration import CollectionFormatClientConfiguration @@ -151,53 +150,6 @@ async def ssv(self, *, colors: List[str], **kwargs: Any) -> None: if cls: return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async - async def tsv(self, *, colors: List[str], **kwargs: Any) -> None: - """tsv. - - :keyword colors: Possible values for colors are [blue,red,green]. Required. - :paramtype colors: list[str] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_tsv_request( - colors=colors, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async async def pipes(self, *, colors: List[str], **kwargs: Any) -> None: """pipes. diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/operations/_operations.py b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/operations/_operations.py index 2ee5d87e987..acc529a3411 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/operations/_operations.py @@ -60,18 +60,6 @@ def build_query_ssv_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, **kwargs) -def build_query_tsv_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - # Construct URL - _url = "/parameters/collection-format/query/tsv" - - # Construct parameters - _params["colors"] = _SERIALIZER.query("colors", colors, "[str]", div=" ") - - return HttpRequest(method="GET", url=_url, params=_params, **kwargs) - - def build_query_pipes_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -219,53 +207,6 @@ def ssv(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=i if cls: return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace - def tsv(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """tsv. - - :keyword colors: Possible values for colors are [blue,red,green]. Required. - :paramtype colors: list[str] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_tsv_request( - colors=colors, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace def pipes(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """pipes. diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index e7130642107..1e8b5c1dbce 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -44,7 +44,7 @@ def build_status_code_range_error_response_status_code_in_range_request( # pyli ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/response/status-code-range/error-response-status-code-in-range" @@ -60,7 +60,7 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/response/status-code-range/error-response-status-code-404" @@ -127,7 +127,7 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -186,7 +186,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index 277e08f3644..7029ac14e54 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -95,7 +95,7 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -154,7 +154,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py index 3fb191aaf4f..5601a8af2e2 100644 --- a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py +++ b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py @@ -20,7 +20,7 @@ class JsonClient: # pylint: disable=client-accepts-api-version-keyword - """Projection. + """Encoded names. :ivar property: PropertyOperations operations :vartype property: serialization.encodedname.json.operations.PropertyOperations diff --git a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py index 560d2f21056..4f0c8e14015 100644 --- a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py @@ -20,7 +20,7 @@ class JsonClient: # pylint: disable=client-accepts-api-version-keyword - """Projection. + """Encoded names. :ivar property: PropertyOperations operations :vartype property: serialization.encodedname.json.aio.operations.PropertyOperations diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/CHANGELOG.md b/packages/typespec-python/test/azure/generated/streaming-jsonl/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/LICENSE b/packages/typespec-python/test/azure/generated/streaming-jsonl/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/MANIFEST.in b/packages/typespec-python/test/azure/generated/streaming-jsonl/MANIFEST.in new file mode 100644 index 00000000000..0535e9d52c8 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include LICENSE +include streaming/jsonl/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include streaming/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/README.md b/packages/typespec-python/test/azure/generated/streaming-jsonl/README.md new file mode 100644 index 00000000000..5bf164c3cfa --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/README.md @@ -0,0 +1,45 @@ + + +# Streaming Jsonl client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install streaming-jsonl +``` + +#### Prequisites + +- Python 3.8 or later is required to use this package. +- You need an [Azure subscription][azure_sub] to use this package. +- An existing Streaming Jsonl instance. + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + + +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials +[azure_identity_pip]: https://pypi.org/project/azure-identity/ +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential +[pip]: https://pypi.org/project/pip/ +[azure_sub]: https://azure.microsoft.com/free/ + diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/apiview-properties.json b/packages/typespec-python/test/azure/generated/streaming-jsonl/apiview-properties.json new file mode 100644 index 00000000000..f9c7a57ae46 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/apiview-properties.json @@ -0,0 +1,7 @@ +{ + "CrossLanguagePackageId": "Streaming.Jsonl", + "CrossLanguageDefinitionId": { + "streaming.jsonl.JsonlClient.basic.send": "Streaming.Jsonl.Basic.send", + "streaming.jsonl.JsonlClient.basic.receive": "Streaming.Jsonl.Basic.receive" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/dev_requirements.txt b/packages/typespec-python/test/azure/generated/streaming-jsonl/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/conftest.py new file mode 100644 index 00000000000..2c84d079384 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + jsonl_subscription_id = os.environ.get("JSONL_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + jsonl_tenant_id = os.environ.get("JSONL_TENANT_ID", "00000000-0000-0000-0000-000000000000") + jsonl_client_id = os.environ.get("JSONL_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + jsonl_client_secret = os.environ.get("JSONL_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=jsonl_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=jsonl_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=jsonl_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=jsonl_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations.py similarity index 51% rename from packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations.py rename to packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations.py index d783fba2a7e..45c586dfb8a 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations.py +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations.py @@ -7,27 +7,28 @@ # -------------------------------------------------------------------------- import pytest from devtools_testutils import recorded_by_proxy -from testpreparer import AdditionalPropertiesClientTestBase, AdditionalPropertiesPreparer +from testpreparer import JsonlClientTestBase, JsonlPreparer @pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestAdditionalPropertiesSpreadRecordDiscriminatedUnionOperations(AdditionalPropertiesClientTestBase): - @AdditionalPropertiesPreparer() +class TestJsonlBasicOperations(JsonlClientTestBase): + @JsonlPreparer() @recorded_by_proxy - def test_spread_record_discriminated_union_get(self, additionalproperties_endpoint): - client = self.create_client(endpoint=additionalproperties_endpoint) - response = client.spread_record_discriminated_union.get() + def test_basic_send(self, jsonl_endpoint): + client = self.create_client(endpoint=jsonl_endpoint) + response = client.basic.send( + body=bytes("bytes", encoding="utf-8"), + content_type="str", + ) # please add some check logic here by yourself # ... - @AdditionalPropertiesPreparer() + @JsonlPreparer() @recorded_by_proxy - def test_spread_record_discriminated_union_put(self, additionalproperties_endpoint): - client = self.create_client(endpoint=additionalproperties_endpoint) - response = client.spread_record_discriminated_union.put( - body={"name": "str"}, - ) + def test_basic_receive(self, jsonl_endpoint): + client = self.create_client(endpoint=jsonl_endpoint) + response = client.basic.receive() # please add some check logic here by yourself # ... diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations_async.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations_async.py new file mode 100644 index 00000000000..7ed2974d246 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/test_jsonl_basic_operations_async.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import JsonlPreparer +from testpreparer_async import JsonlClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestJsonlBasicOperationsAsync(JsonlClientTestBaseAsync): + @JsonlPreparer() + @recorded_by_proxy_async + async def test_basic_send(self, jsonl_endpoint): + client = self.create_async_client(endpoint=jsonl_endpoint) + response = await client.basic.send( + body=bytes("bytes", encoding="utf-8"), + content_type="str", + ) + + # please add some check logic here by yourself + # ... + + @JsonlPreparer() + @recorded_by_proxy_async + async def test_basic_receive(self, jsonl_endpoint): + client = self.create_async_client(endpoint=jsonl_endpoint) + response = await client.basic.receive() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer.py new file mode 100644 index 00000000000..31bfc40f948 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools +from streaming.jsonl import JsonlClient + + +class JsonlClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(JsonlClient) + return self.create_client_from_credential( + JsonlClient, + credential=credential, + endpoint=endpoint, + ) + + +JsonlPreparer = functools.partial(PowerShellPreparer, "jsonl", jsonl_endpoint="https://fake_jsonl_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..b97ab87659c --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase +from streaming.jsonl.aio import JsonlClient + + +class JsonlClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(JsonlClient, is_async=True) + return self.create_client_from_credential( + JsonlClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/setup.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/setup.py new file mode 100644 index 00000000000..53a80035f7b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/setup.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "streaming-jsonl" +PACKAGE_PPRINT_NAME = "Streaming Jsonl" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "streaming", + ] + ), + include_package_data=True, + package_data={ + "streaming.jsonl": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/__init__.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/__init__.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/__init__.py new file mode 100644 index 00000000000..7e7bd7ff8dc --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/__init__.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import JsonlClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "JsonlClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_client.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_client.py new file mode 100644 index 00000000000..568e6702876 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_client.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import JsonlClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import BasicOperations + + +class JsonlClient: # pylint: disable=client-accepts-api-version-keyword + """Test of jsonl streaming. + + :ivar basic: BasicOperations operations + :vartype basic: streaming.jsonl.operations.BasicOperations + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = JsonlClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_configuration.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_configuration.py new file mode 100644 index 00000000000..d24e0b3e02e --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_configuration.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class JsonlClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for JsonlClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "streaming-jsonl/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_model_base.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_patch.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_serialization.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_serialization.py new file mode 100644 index 00000000000..7a0232de5dd --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_version.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py new file mode 100644 index 00000000000..9a9302e2262 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import JsonlClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "JsonlClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_client.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_client.py new file mode 100644 index 00000000000..c4c7bbd07c1 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_client.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import JsonlClientConfiguration +from .operations import BasicOperations + + +class JsonlClient: # pylint: disable=client-accepts-api-version-keyword + """Test of jsonl streaming. + + :ivar basic: BasicOperations operations + :vartype basic: streaming.jsonl.aio.operations.BasicOperations + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = JsonlClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py new file mode 100644 index 00000000000..4d134725b69 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class JsonlClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for JsonlClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "streaming-jsonl/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/__init__.py new file mode 100644 index 00000000000..c9a013c3dd2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import BasicOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BasicOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_operations.py new file mode 100644 index 00000000000..5cd53de149e --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_operations.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ..._serialization import Deserializer, Serializer +from ...operations._operations import build_basic_receive_request, build_basic_send_request +from .._configuration import JsonlClientConfiguration + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BasicOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~streaming.jsonl.aio.JsonlClient`'s + :attr:`basic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: JsonlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def send(self, body: bytes, **kwargs: Any) -> None: + """send. + + :param body: Required. + :type body: bytes + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/jsonl")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_basic_send_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def receive(self, **kwargs: Any) -> AsyncIterator[bytes]: + """receive. + + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_basic_receive_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_patch.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/__init__.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/__init__.py new file mode 100644 index 00000000000..c9a013c3dd2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import BasicOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BasicOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_operations.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_operations.py new file mode 100644 index 00000000000..eb9bd83cd1b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_operations.py @@ -0,0 +1,190 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterator, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .._configuration import JsonlClientConfiguration +from .._serialization import Deserializer, Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_basic_send_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: str = kwargs.pop("content_type") + # Construct URL + _url = "/streaming/jsonl/basic/send" + + # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_basic_receive_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/jsonl") + + # Construct URL + _url = "/streaming/jsonl/basic/receive" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class BasicOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~streaming.jsonl.JsonlClient`'s + :attr:`basic` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: JsonlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def send(self, body: bytes, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """send. + + :param body: Required. + :type body: bytes + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/jsonl")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_basic_send_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def receive(self, **kwargs: Any) -> Iterator[bytes]: + """receive. + + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_basic_receive_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_patch.py b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/py.typed b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/streaming-jsonl/streaming/jsonl/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py index e6ebacfe522..8aa1318e410 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -26,7 +25,7 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import _deserialize from ..._serialization import Deserializer, Serializer from ...operations._operations import ( build_string_get_known_value_request, @@ -110,7 +109,7 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -166,7 +165,7 @@ async def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWee if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -195,10 +194,10 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekExtensibleEnu _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_known_value_request( content_type=content_type, @@ -247,10 +246,10 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekExtensibleE _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py index 3b910679b0d..acdfc6e4e60 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -27,7 +26,7 @@ from .. import models as _models from .._configuration import ExtensibleClientConfiguration -from .._model_base import SdkJSONEncoder, _deserialize +from .._model_base import _deserialize from .._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -44,7 +43,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/enum/extensible/string/known-value" @@ -58,7 +57,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: def build_string_get_unknown_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/enum/extensible/string/unknown-value" @@ -161,7 +160,7 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExtensi if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -217,7 +216,7 @@ def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExten if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -248,10 +247,10 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_known_value_request( content_type=content_type, @@ -302,10 +301,10 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/apiview-properties.json b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/apiview-properties.json index a03c3db179d..c7916a6249c 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/apiview-properties.json @@ -30,7 +30,6 @@ "typetest.property.additionalproperties.models.SpreadFloatRecord": "Type.Property.AdditionalProperties.SpreadFloatRecord", "typetest.property.additionalproperties.models.SpreadModelArrayRecord": "Type.Property.AdditionalProperties.SpreadModelArrayRecord", "typetest.property.additionalproperties.models.SpreadModelRecord": "Type.Property.AdditionalProperties.SpreadModelRecord", - "typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForDiscriminatedUnion", "typetest.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion", "typetest.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion2": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion2", "typetest.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion3": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion3", @@ -95,8 +94,6 @@ "typetest.property.additionalproperties.AdditionalPropertiesClient.multiple_spread.put": "Type.Property.AdditionalProperties.MultipleSpread.put", "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_union.get": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_union.put": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", - "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_discriminated_union.get": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", - "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_discriminated_union.put": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_non_discriminated_union.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_non_discriminated_union.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", "typetest.property.additionalproperties.AdditionalPropertiesClient.spread_record_non_discriminated_union2.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations_async.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations_async.py deleted file mode 100644 index f9afa893275..00000000000 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/generated_tests/test_additional_properties_spread_record_discriminated_union_operations_async.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils.aio import recorded_by_proxy_async -from testpreparer import AdditionalPropertiesPreparer -from testpreparer_async import AdditionalPropertiesClientTestBaseAsync - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestAdditionalPropertiesSpreadRecordDiscriminatedUnionOperationsAsync(AdditionalPropertiesClientTestBaseAsync): - @AdditionalPropertiesPreparer() - @recorded_by_proxy_async - async def test_spread_record_discriminated_union_get(self, additionalproperties_endpoint): - client = self.create_async_client(endpoint=additionalproperties_endpoint) - response = await client.spread_record_discriminated_union.get() - - # please add some check logic here by yourself - # ... - - @AdditionalPropertiesPreparer() - @recorded_by_proxy_async - async def test_spread_record_discriminated_union_put(self, additionalproperties_endpoint): - client = self.create_async_client(endpoint=additionalproperties_endpoint) - response = await client.spread_record_discriminated_union.put( - body={"name": "str"}, - ) - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py index cc7416a5b25..e7a430ca381 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py @@ -43,7 +43,6 @@ SpreadFloatOperations, SpreadModelArrayOperations, SpreadModelOperations, - SpreadRecordDiscriminatedUnionOperations, SpreadRecordNonDiscriminatedUnion2Operations, SpreadRecordNonDiscriminatedUnion3Operations, SpreadRecordNonDiscriminatedUnionOperations, @@ -134,9 +133,6 @@ class AdditionalPropertiesClient: # pylint: disable=client-accepts-api-version- :ivar spread_record_union: SpreadRecordUnionOperations operations :vartype spread_record_union: typetest.property.additionalproperties.operations.SpreadRecordUnionOperations - :ivar spread_record_discriminated_union: SpreadRecordDiscriminatedUnionOperations operations - :vartype spread_record_discriminated_union: - typetest.property.additionalproperties.operations.SpreadRecordDiscriminatedUnionOperations :ivar spread_record_non_discriminated_union: SpreadRecordNonDiscriminatedUnionOperations operations :vartype spread_record_non_discriminated_union: @@ -238,9 +234,6 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.spread_record_union = SpreadRecordUnionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.spread_record_discriminated_union = SpreadRecordDiscriminatedUnionOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.spread_record_non_discriminated_union = SpreadRecordNonDiscriminatedUnionOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py index 743f9783cff..547d4a108f7 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py @@ -43,7 +43,6 @@ SpreadFloatOperations, SpreadModelArrayOperations, SpreadModelOperations, - SpreadRecordDiscriminatedUnionOperations, SpreadRecordNonDiscriminatedUnion2Operations, SpreadRecordNonDiscriminatedUnion3Operations, SpreadRecordNonDiscriminatedUnionOperations, @@ -136,9 +135,6 @@ class AdditionalPropertiesClient: # pylint: disable=client-accepts-api-version- :ivar spread_record_union: SpreadRecordUnionOperations operations :vartype spread_record_union: typetest.property.additionalproperties.aio.operations.SpreadRecordUnionOperations - :ivar spread_record_discriminated_union: SpreadRecordDiscriminatedUnionOperations operations - :vartype spread_record_discriminated_union: - typetest.property.additionalproperties.aio.operations.SpreadRecordDiscriminatedUnionOperations :ivar spread_record_non_discriminated_union: SpreadRecordNonDiscriminatedUnionOperations operations :vartype spread_record_non_discriminated_union: @@ -240,9 +236,6 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.spread_record_union = SpreadRecordUnionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.spread_record_discriminated_union = SpreadRecordDiscriminatedUnionOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.spread_record_non_discriminated_union = SpreadRecordNonDiscriminatedUnionOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py index e6352d8100e..5cb7c3e9a72 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py @@ -40,7 +40,6 @@ from ._operations import ExtendsDifferentSpreadModelArrayOperations # type: ignore from ._operations import MultipleSpreadOperations # type: ignore from ._operations import SpreadRecordUnionOperations # type: ignore -from ._operations import SpreadRecordDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion2Operations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion3Operations # type: ignore @@ -78,7 +77,6 @@ "ExtendsDifferentSpreadModelArrayOperations", "MultipleSpreadOperations", "SpreadRecordUnionOperations", - "SpreadRecordDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnion2Operations", "SpreadRecordNonDiscriminatedUnion3Operations", diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py index f5ba2514fbc..606b1e954e0 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py @@ -83,8 +83,6 @@ build_spread_model_array_put_request, build_spread_model_get_request, build_spread_model_put_request, - build_spread_record_discriminated_union_get_request, - build_spread_record_discriminated_union_put_request, build_spread_record_non_discriminated_union2_get_request, build_spread_record_non_discriminated_union2_put_request, build_spread_record_non_discriminated_union3_get_request, @@ -5153,185 +5151,6 @@ async def put(self, body: Union[_models.SpreadRecordForUnion, JSON, IO[bytes]], return cls(pipeline_response, None, {}) # type: ignore -class SpreadRecordDiscriminatedUnionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~typetest.property.additionalproperties.aio.AdditionalPropertiesClient`'s - :attr:`spread_record_discriminated_union` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AdditionalPropertiesClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.SpreadRecordForDiscriminatedUnion: - """Get call. - - :return: SpreadRecordForDiscriminatedUnion. The SpreadRecordForDiscriminatedUnion is compatible - with MutableMapping - :rtype: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SpreadRecordForDiscriminatedUnion] = kwargs.pop("cls", None) - - _request = build_spread_record_discriminated_union_get_request( - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.SpreadRecordForDiscriminatedUnion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def put( - self, body: _models.SpreadRecordForDiscriminatedUnion, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put(self, body: Union[_models.SpreadRecordForDiscriminatedUnion, JSON, IO[bytes]], **kwargs: Any) -> None: - """Put operation. - - :param body: body. Is one of the following types: SpreadRecordForDiscriminatedUnion, JSON, - IO[bytes] Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion or - JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_spread_record_discriminated_union_put_request( - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - class SpreadRecordNonDiscriminatedUnionOperations: # pylint: disable=name-too-long """ .. warning:: diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py index 94caec2ae22..b367be58424 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py @@ -43,7 +43,6 @@ SpreadFloatRecord, SpreadModelArrayRecord, SpreadModelRecord, - SpreadRecordForDiscriminatedUnion, SpreadRecordForNonDiscriminatedUnion, SpreadRecordForNonDiscriminatedUnion2, SpreadRecordForNonDiscriminatedUnion3, @@ -87,7 +86,6 @@ "SpreadFloatRecord", "SpreadModelArrayRecord", "SpreadModelRecord", - "SpreadRecordForDiscriminatedUnion", "SpreadRecordForNonDiscriminatedUnion", "SpreadRecordForNonDiscriminatedUnion2", "SpreadRecordForNonDiscriminatedUnion3", diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 72db540cb29..05289245c58 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -924,34 +924,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SpreadRecordForDiscriminatedUnion(_model_base.Model): - """The model spread Record. - - :ivar name: The name property. Required. - :vartype name: str - """ - - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name property. Required.""" - - @overload - def __init__( - self, - *, - name: str, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class SpreadRecordForNonDiscriminatedUnion(_model_base.Model): """The model spread Record. diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py index e6352d8100e..5cb7c3e9a72 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py @@ -40,7 +40,6 @@ from ._operations import ExtendsDifferentSpreadModelArrayOperations # type: ignore from ._operations import MultipleSpreadOperations # type: ignore from ._operations import SpreadRecordUnionOperations # type: ignore -from ._operations import SpreadRecordDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion2Operations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion3Operations # type: ignore @@ -78,7 +77,6 @@ "ExtendsDifferentSpreadModelArrayOperations", "MultipleSpreadOperations", "SpreadRecordUnionOperations", - "SpreadRecordDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnion2Operations", "SpreadRecordNonDiscriminatedUnion3Operations", diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py index b24e582a88c..cb5729dd47f 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py @@ -832,34 +832,6 @@ def build_spread_record_union_put_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_spread_record_discriminated_union_get_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion" - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) - - -def build_spread_record_discriminated_union_put_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) - - def build_spread_record_non_discriminated_union_get_request( # pylint: disable=name-too-long **kwargs: Any, ) -> HttpRequest: @@ -6036,187 +6008,6 @@ def put( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore -class SpreadRecordDiscriminatedUnionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~typetest.property.additionalproperties.AdditionalPropertiesClient`'s - :attr:`spread_record_discriminated_union` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AdditionalPropertiesClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, **kwargs: Any) -> _models.SpreadRecordForDiscriminatedUnion: - """Get call. - - :return: SpreadRecordForDiscriminatedUnion. The SpreadRecordForDiscriminatedUnion is compatible - with MutableMapping - :rtype: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SpreadRecordForDiscriminatedUnion] = kwargs.pop("cls", None) - - _request = build_spread_record_discriminated_union_get_request( - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.SpreadRecordForDiscriminatedUnion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def put( - self, body: _models.SpreadRecordForDiscriminatedUnion, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( # pylint: disable=inconsistent-return-statements - self, body: Union[_models.SpreadRecordForDiscriminatedUnion, JSON, IO[bytes]], **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Is one of the following types: SpreadRecordForDiscriminatedUnion, JSON, - IO[bytes] Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion or - JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_spread_record_discriminated_union_put_request( - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - class SpreadRecordNonDiscriminatedUnionOperations: # pylint: disable=name-too-long """ .. warning:: diff --git a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py index 10d1f90f853..2d22780ef38 100644 --- a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py @@ -123,7 +123,7 @@ async def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -151,10 +151,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_request( content_type=content_type, @@ -248,7 +248,7 @@ async def get(self, **kwargs: Any) -> bool: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.json()) + deserialized = _deserialize(bool, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -276,10 +276,10 @@ async def put(self, body: bool, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_boolean_put_request( content_type=content_type, @@ -498,7 +498,7 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -526,10 +526,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_type_request_body_request( content_type=content_type, @@ -670,7 +670,7 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -698,10 +698,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -870,10 +870,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_verify_verify_request( content_type=content_type, @@ -995,10 +995,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py index 54eadb66341..de60340c8e9 100644 --- a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py @@ -45,7 +45,7 @@ def build_string_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/string" @@ -72,7 +72,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: def build_boolean_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/boolean" @@ -126,7 +126,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: def build_decimal_type_response_body_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/decimal/response_body" @@ -167,7 +167,7 @@ def build_decimal_type_request_parameter_request( # pylint: disable=name-too-lo def build_decimal128_type_response_body_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/decimal128/response_body" @@ -325,7 +325,7 @@ def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -353,10 +353,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_request( content_type=content_type, @@ -450,7 +450,7 @@ def get(self, **kwargs: Any) -> bool: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.json()) + deserialized = _deserialize(bool, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -478,10 +478,10 @@ def put(self, body: bool, **kwargs: Any) -> None: # pylint: disable=inconsisten _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_boolean_put_request( content_type=content_type, @@ -700,7 +700,7 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -730,10 +730,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_type_request_body_request( content_type=content_type, @@ -876,7 +876,7 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -906,10 +906,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -1080,10 +1080,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_verify_verify_request( content_type=content_type, @@ -1205,10 +1205,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index e186a185abe..23f9a67abb7 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -24,7 +23,7 @@ from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict -from .._model_base import SdkJSONEncoder, _deserialize +from .._model_base import _deserialize from .._serialization import Serializer from .._vendor import ReturnTypeChangedFromClientMixinABC @@ -43,7 +42,7 @@ def build_return_type_changed_from_test_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: str = kwargs.pop("content_type") - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/test" @@ -78,10 +77,10 @@ def test(self, body: str, **kwargs: Any) -> str: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[str] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_return_type_changed_from_test_request( content_type=content_type, @@ -114,7 +113,7 @@ def test(self, body: str, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index 8a6d8510cc6..7ce1477e2c7 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -25,7 +24,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import _deserialize from ..._operations._operations import build_return_type_changed_from_test_request from .._vendor import ReturnTypeChangedFromClientMixinABC @@ -60,10 +59,10 @@ async def test(self, body: str, **kwargs: Any) -> str: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[str] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_return_type_changed_from_test_request( content_type=content_type, @@ -96,7 +95,7 @@ async def test(self, body: str, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py index 6f2441efa0a..03954dc7bb8 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -22,7 +21,6 @@ from corehttp.runtime.pipeline import PipelineResponse from corehttp.utils import case_insensitive_dict -from ...._model_base import SdkJSONEncoder from ...._serialization import Deserializer, Serializer from ....aio._configuration import BytesClientConfiguration from ...operations._operations import ( @@ -78,10 +76,10 @@ async def default(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_default_request( content_type=content_type, @@ -222,10 +220,10 @@ async def base64(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_base64_request( content_type=content_type, @@ -270,10 +268,10 @@ async def base64_url(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore + _content = value _request = build_request_body_base64_url_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py index 317c6687534..e56495b334a 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -23,7 +22,6 @@ from corehttp.utils import case_insensitive_dict from ..._configuration import BytesClientConfiguration -from ..._model_base import SdkJSONEncoder from ..._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -139,10 +137,10 @@ def default(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_default_request( content_type=content_type, @@ -285,10 +283,10 @@ def base64(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incons _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore + _content = value _request = build_request_body_base64_request( content_type=content_type, @@ -333,10 +331,10 @@ def base64_url(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=in _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore + _content = value _request = build_request_body_base64_url_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py index 6b0e5ca2f12..91881cc5782 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py @@ -22,7 +22,6 @@ from corehttp.runtime import AsyncPipelineClient from corehttp.runtime.pipeline import PipelineResponse -from ...._model_base import _deserialize from ...._serialization import Deserializer, Serializer from ....aio._configuration import BytesClientConfiguration from ...operations._operations import ( @@ -58,11 +57,11 @@ def __init__(self, *args, **kwargs) -> None: self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def default(self, **kwargs: Any) -> bytes: + async def default(self, **kwargs: Any) -> AsyncIterator[bytes]: """default. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -76,7 +75,7 @@ async def default(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_default_request( headers=_headers, @@ -87,7 +86,7 @@ async def default(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -101,10 +100,7 @@ async def default(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -217,11 +213,11 @@ async def custom_content_type(self, **kwargs: Any) -> AsyncIterator[bytes]: return deserialized # type: ignore - async def base64(self, **kwargs: Any) -> bytes: + async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: """base64. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -235,7 +231,7 @@ async def base64(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -246,7 +242,7 @@ async def base64(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -260,21 +256,18 @@ async def base64(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def base64_url(self, **kwargs: Any) -> bytes: + async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: """base64_url. - :return: bytes - :rtype: bytes + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -288,7 +281,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -299,7 +292,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -313,10 +306,7 @@ async def base64_url(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64url") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py index f3a2be1308e..fd2fac2bab8 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py @@ -24,7 +24,6 @@ from corehttp.utils import case_insensitive_dict from ..._configuration import BytesClientConfiguration -from ..._model_base import _deserialize from ..._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -41,7 +40,7 @@ def build_response_body_default_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/octet-stream") # Construct URL _url = "/encode/bytes/body/response/default" @@ -83,7 +82,7 @@ def build_response_body_custom_content_type_request(**kwargs: Any) -> HttpReques def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/octet-stream") # Construct URL _url = "/encode/bytes/body/response/base64" @@ -97,7 +96,7 @@ def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: def build_response_body_base64_url_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/encode/bytes/body/response/base64url" @@ -125,11 +124,11 @@ def __init__(self, *args, **kwargs): self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def default(self, **kwargs: Any) -> bytes: + def default(self, **kwargs: Any) -> Iterator[bytes]: """default. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -143,7 +142,7 @@ def default(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_default_request( headers=_headers, @@ -154,7 +153,7 @@ def default(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -168,10 +167,7 @@ def default(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -284,11 +280,11 @@ def custom_content_type(self, **kwargs: Any) -> Iterator[bytes]: return deserialized # type: ignore - def base64(self, **kwargs: Any) -> bytes: + def base64(self, **kwargs: Any) -> Iterator[bytes]: """base64. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -302,7 +298,7 @@ def base64(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -313,7 +309,7 @@ def base64(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -327,21 +323,18 @@ def base64(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def base64_url(self, **kwargs: Any) -> bytes: + def base64_url(self, **kwargs: Any) -> Iterator[bytes]: """base64_url. - :return: bytes - :rtype: bytes + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -355,7 +348,7 @@ def base64_url(self, **kwargs: Any) -> bytes: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[bytes] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -366,7 +359,7 @@ def base64_url(self, **kwargs: Any) -> bytes: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -380,10 +373,7 @@ def base64_url(self, **kwargs: Any) -> bytes: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(bytes, response.json(), format="base64url") + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/aio/operations/_operations.py index 4c96be1ba38..2e4981a90ce 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/aio/operations/_operations.py @@ -27,7 +27,6 @@ build_query_multi_request, build_query_pipes_request, build_query_ssv_request, - build_query_tsv_request, ) if sys.version_info >= (3, 9): @@ -143,50 +142,6 @@ async def ssv(self, *, colors: List[str], **kwargs: Any) -> None: if cls: return cls(pipeline_response, None, {}) # type: ignore - async def tsv(self, *, colors: List[str], **kwargs: Any) -> None: - """tsv. - - :keyword colors: Possible values for colors are [blue,red,green]. Required. - :paramtype colors: list[str] - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_tsv_request( - colors=colors, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - async def pipes(self, *, colors: List[str], **kwargs: Any) -> None: """pipes. diff --git a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/operations/_operations.py index 22e80f2c13a..82e27455b00 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/query/operations/_operations.py @@ -59,18 +59,6 @@ def build_query_ssv_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, **kwargs) -def build_query_tsv_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - # Construct URL - _url = "/parameters/collection-format/query/tsv" - - # Construct parameters - _params["colors"] = _SERIALIZER.query("colors", colors, "[str]", div=" ") - - return HttpRequest(method="GET", url=_url, params=_params, **kwargs) - - def build_query_pipes_request(*, colors: List[str], **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -200,50 +188,6 @@ def ssv(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=i if cls: return cls(pipeline_response, None, {}) # type: ignore - def tsv(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """tsv. - - :keyword colors: Possible values for colors are [blue,red,green]. Required. - :paramtype colors: list[str] - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_tsv_request( - colors=colors, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - def pipes(self, *, colors: List[str], **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """pipes. diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index 3f507c9bcec..3c284b44606 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -43,7 +43,7 @@ def build_status_code_range_error_response_status_code_in_range_request( # pyli ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/response/status-code-range/error-response-status-code-in-range" @@ -59,7 +59,7 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/response/status-code-range/error-response-status-code-404" @@ -123,7 +123,7 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -179,7 +179,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index ddff2b497d7..21d4c0a0903 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -92,7 +92,7 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -150,7 +150,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Literal[204], response.json()) + deserialized = _deserialize(Literal[204], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py index 3ce23da81ba..a6917000930 100644 --- a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py +++ b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_client.py @@ -19,7 +19,7 @@ class JsonClient: # pylint: disable=client-accepts-api-version-keyword - """Projection. + """Encoded names. :ivar property: PropertyOperations operations :vartype property: serialization.encodedname.json.operations.PropertyOperations diff --git a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py index 912059d165f..62aa9c0c894 100644 --- a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/aio/_client.py @@ -19,7 +19,7 @@ class JsonClient: # pylint: disable=client-accepts-api-version-keyword - """Projection. + """Encoded names. :ivar property: PropertyOperations operations :vartype property: serialization.encodedname.json.aio.operations.PropertyOperations diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/CHANGELOG.md b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/LICENSE b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/LICENSE new file mode 100644 index 00000000000..edd3f78edcc --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Unbranded Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/MANIFEST.in b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/MANIFEST.in new file mode 100644 index 00000000000..0535e9d52c8 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include LICENSE +include streaming/jsonl/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include streaming/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/README.md b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/setup.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/setup.py new file mode 100644 index 00000000000..aae2f5daf2f --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/setup.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "streaming-jsonl" +PACKAGE_PPRINT_NAME = "Streaming Jsonl" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Unbranded {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Unbranded Corporation", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "streaming", + ] + ), + include_package_data=True, + package_data={ + "streaming.jsonl": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "corehttp[requests]", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/__init__.py new file mode 100644 index 00000000000..2d0d2e59ba3 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/__init__.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import JsonlClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "JsonlClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_client.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_client.py new file mode 100644 index 00000000000..fe0b3a3f7df --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_client.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from corehttp.rest import HttpRequest, HttpResponse +from corehttp.runtime import PipelineClient, policies + +from ._configuration import JsonlClientConfiguration +from ._serialization import Deserializer, Serializer +from .basic.operations import BasicOperations + + +class JsonlClient: # pylint: disable=client-accepts-api-version-keyword + """Test of jsonl streaming. + + :ivar basic: BasicOperations operations + :vartype basic: streaming.jsonl.operations.BasicOperations + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = JsonlClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.retry_policy, + self._config.authentication_policy, + self._config.logging_policy, + ] + self._client: PipelineClient = PipelineClient(endpoint=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from corehttp.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~corehttp.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~corehttp.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_configuration.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_configuration.py new file mode 100644 index 00000000000..c90a96aea14 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from corehttp.runtime import policies + +from ._version import VERSION + + +class JsonlClientConfiguration: + """Configuration for JsonlClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "streaming-jsonl/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_model_base.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_model_base.py new file mode 100644 index 00000000000..86f9838e356 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from corehttp.exceptions import DeserializationError +from corehttp.utils import CaseInsensitiveEnumMeta +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_patch.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_serialization.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_serialization.py new file mode 100644 index 00000000000..698532b21a8 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Unbranded Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from corehttp.exceptions import DeserializationError, SerializationError +from corehttp.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_version.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_version.py new file mode 100644 index 00000000000..2a6e487ad06 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py new file mode 100644 index 00000000000..eb9178ac151 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import JsonlClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "JsonlClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_client.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_client.py new file mode 100644 index 00000000000..6c2356a55c4 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_client.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from corehttp.rest import AsyncHttpResponse, HttpRequest +from corehttp.runtime import AsyncPipelineClient, policies + +from .._serialization import Deserializer, Serializer +from ..basic.aio.operations import BasicOperations +from ._configuration import JsonlClientConfiguration + + +class JsonlClient: # pylint: disable=client-accepts-api-version-keyword + """Test of jsonl streaming. + + :ivar basic: BasicOperations operations + :vartype basic: streaming.jsonl.aio.operations.BasicOperations + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = JsonlClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.retry_policy, + self._config.authentication_policy, + self._config.logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(endpoint=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.basic = BasicOperations(self._client, self._config, self._serialize, self._deserialize) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from corehttp.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~corehttp.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~corehttp.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py new file mode 100644 index 00000000000..37bc8f1745c --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from corehttp.runtime import policies + +from .._version import VERSION + + +class JsonlClientConfiguration: + """Configuration for JsonlClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "streaming-jsonl/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/__init__.py new file mode 100644 index 00000000000..76ccb20ac32 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import BasicOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BasicOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_operations.py new file mode 100644 index 00000000000..d5e25300987 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_operations.py @@ -0,0 +1,154 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from corehttp.rest import AsyncHttpResponse, HttpRequest +from corehttp.runtime import AsyncPipelineClient +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.utils import case_insensitive_dict + +from ...._serialization import Deserializer, Serializer +from ....aio._configuration import JsonlClientConfiguration +from ...operations._operations import build_basic_receive_request, build_basic_send_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BasicOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~streaming.jsonl.aio.JsonlClient`'s + :attr:`basic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: JsonlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def send(self, body: bytes, **kwargs: Any) -> None: + """send. + + :param body: Required. + :type body: bytes + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/jsonl")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_basic_send_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def receive(self, **kwargs: Any) -> AsyncIterator[bytes]: + """receive. + + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_basic_receive_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_patch.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/__init__.py new file mode 100644 index 00000000000..76ccb20ac32 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import BasicOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BasicOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_operations.py new file mode 100644 index 00000000000..a22f59e8a9e --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_operations.py @@ -0,0 +1,183 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterator, Optional, TypeVar + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from corehttp.rest import HttpRequest, HttpResponse +from corehttp.runtime import PipelineClient +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.utils import case_insensitive_dict + +from ..._configuration import JsonlClientConfiguration +from ..._serialization import Deserializer, Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_basic_send_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: str = kwargs.pop("content_type") + # Construct URL + _url = "/streaming/jsonl/basic/send" + + # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_basic_receive_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/jsonl") + + # Construct URL + _url = "/streaming/jsonl/basic/receive" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class BasicOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~streaming.jsonl.JsonlClient`'s + :attr:`basic` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: JsonlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def send(self, body: bytes, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """send. + + :param body: Required. + :type body: bytes + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/jsonl")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_basic_send_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def receive(self, **kwargs: Any) -> Iterator[bytes]: + """receive. + + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_basic_receive_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_patch.py b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/basic/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/py.typed b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/streaming-jsonl/streaming/jsonl/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py index d1f0fca37b6..80383534bd9 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -25,7 +24,7 @@ from corehttp.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import _deserialize from ..._serialization import Deserializer, Serializer from ...operations._operations import ( build_string_get_known_value_request, @@ -106,7 +105,7 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -159,7 +158,7 @@ async def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWee if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -187,10 +186,10 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekExtensibleEnu _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_known_value_request( content_type=content_type, @@ -236,10 +235,10 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekExtensibleE _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py index 388c5a232c9..a578119dcf7 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -26,7 +25,7 @@ from .. import models as _models from .._configuration import ExtensibleClientConfiguration -from .._model_base import SdkJSONEncoder, _deserialize +from .._model_base import _deserialize from .._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -43,7 +42,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/enum/extensible/string/known-value" @@ -57,7 +56,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: def build_string_get_unknown_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/enum/extensible/string/unknown-value" @@ -157,7 +156,7 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExtensi if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -210,7 +209,7 @@ def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExten if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -240,10 +239,10 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_known_value_request( content_type=content_type, @@ -291,10 +290,10 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py index 3e7ed249d9a..40bd3730656 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_client.py @@ -42,7 +42,6 @@ SpreadFloatOperations, SpreadModelArrayOperations, SpreadModelOperations, - SpreadRecordDiscriminatedUnionOperations, SpreadRecordNonDiscriminatedUnion2Operations, SpreadRecordNonDiscriminatedUnion3Operations, SpreadRecordNonDiscriminatedUnionOperations, @@ -133,9 +132,6 @@ class AdditionalPropertiesClient: # pylint: disable=client-accepts-api-version- :ivar spread_record_union: SpreadRecordUnionOperations operations :vartype spread_record_union: typetest.property.additionalproperties.operations.SpreadRecordUnionOperations - :ivar spread_record_discriminated_union: SpreadRecordDiscriminatedUnionOperations operations - :vartype spread_record_discriminated_union: - typetest.property.additionalproperties.operations.SpreadRecordDiscriminatedUnionOperations :ivar spread_record_non_discriminated_union: SpreadRecordNonDiscriminatedUnionOperations operations :vartype spread_record_non_discriminated_union: @@ -231,9 +227,6 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.spread_record_union = SpreadRecordUnionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.spread_record_discriminated_union = SpreadRecordDiscriminatedUnionOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.spread_record_non_discriminated_union = SpreadRecordNonDiscriminatedUnionOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py index b239e0f91c3..8aefdfb6fb1 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/_client.py @@ -42,7 +42,6 @@ SpreadFloatOperations, SpreadModelArrayOperations, SpreadModelOperations, - SpreadRecordDiscriminatedUnionOperations, SpreadRecordNonDiscriminatedUnion2Operations, SpreadRecordNonDiscriminatedUnion3Operations, SpreadRecordNonDiscriminatedUnionOperations, @@ -135,9 +134,6 @@ class AdditionalPropertiesClient: # pylint: disable=client-accepts-api-version- :ivar spread_record_union: SpreadRecordUnionOperations operations :vartype spread_record_union: typetest.property.additionalproperties.aio.operations.SpreadRecordUnionOperations - :ivar spread_record_discriminated_union: SpreadRecordDiscriminatedUnionOperations operations - :vartype spread_record_discriminated_union: - typetest.property.additionalproperties.aio.operations.SpreadRecordDiscriminatedUnionOperations :ivar spread_record_non_discriminated_union: SpreadRecordNonDiscriminatedUnionOperations operations :vartype spread_record_non_discriminated_union: @@ -233,9 +229,6 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.spread_record_union = SpreadRecordUnionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.spread_record_discriminated_union = SpreadRecordDiscriminatedUnionOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.spread_record_non_discriminated_union = SpreadRecordNonDiscriminatedUnionOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py index fcc6196e83c..02040315ef4 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/__init__.py @@ -40,7 +40,6 @@ from ._operations import ExtendsDifferentSpreadModelArrayOperations # type: ignore from ._operations import MultipleSpreadOperations # type: ignore from ._operations import SpreadRecordUnionOperations # type: ignore -from ._operations import SpreadRecordDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion2Operations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion3Operations # type: ignore @@ -78,7 +77,6 @@ "ExtendsDifferentSpreadModelArrayOperations", "MultipleSpreadOperations", "SpreadRecordUnionOperations", - "SpreadRecordDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnion2Operations", "SpreadRecordNonDiscriminatedUnion3Operations", diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py index c65e5e16e26..34506475a29 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/aio/operations/_operations.py @@ -82,8 +82,6 @@ build_spread_model_array_put_request, build_spread_model_get_request, build_spread_model_put_request, - build_spread_record_discriminated_union_get_request, - build_spread_record_discriminated_union_put_request, build_spread_record_non_discriminated_union2_get_request, build_spread_record_non_discriminated_union2_put_request, build_spread_record_non_discriminated_union3_get_request, @@ -4984,179 +4982,6 @@ async def put(self, body: Union[_models.SpreadRecordForUnion, JSON, IO[bytes]], return cls(pipeline_response, None, {}) # type: ignore -class SpreadRecordDiscriminatedUnionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~typetest.property.additionalproperties.aio.AdditionalPropertiesClient`'s - :attr:`spread_record_discriminated_union` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AdditionalPropertiesClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def get(self, **kwargs: Any) -> _models.SpreadRecordForDiscriminatedUnion: - """Get call. - - :return: SpreadRecordForDiscriminatedUnion. The SpreadRecordForDiscriminatedUnion is compatible - with MutableMapping - :rtype: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SpreadRecordForDiscriminatedUnion] = kwargs.pop("cls", None) - - _request = build_spread_record_discriminated_union_get_request( - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.SpreadRecordForDiscriminatedUnion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def put( - self, body: _models.SpreadRecordForDiscriminatedUnion, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - @overload - async def put(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - @overload - async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - async def put(self, body: Union[_models.SpreadRecordForDiscriminatedUnion, JSON, IO[bytes]], **kwargs: Any) -> None: - """Put operation. - - :param body: body. Is one of the following types: SpreadRecordForDiscriminatedUnion, JSON, - IO[bytes] Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion or - JSON or IO[bytes] - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_spread_record_discriminated_union_put_request( - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - class SpreadRecordNonDiscriminatedUnionOperations: # pylint: disable=name-too-long """ .. warning:: diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py index 5c22c554d5f..d98c7c25ea7 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/__init__.py @@ -43,7 +43,6 @@ SpreadFloatRecord, SpreadModelArrayRecord, SpreadModelRecord, - SpreadRecordForDiscriminatedUnion, SpreadRecordForNonDiscriminatedUnion, SpreadRecordForNonDiscriminatedUnion2, SpreadRecordForNonDiscriminatedUnion3, @@ -87,7 +86,6 @@ "SpreadFloatRecord", "SpreadModelArrayRecord", "SpreadModelRecord", - "SpreadRecordForDiscriminatedUnion", "SpreadRecordForNonDiscriminatedUnion", "SpreadRecordForNonDiscriminatedUnion2", "SpreadRecordForNonDiscriminatedUnion3", diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 1bb3aa395a3..9884cb8391e 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -924,34 +924,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SpreadRecordForDiscriminatedUnion(_model_base.Model): - """The model spread Record. - - :ivar name: The name property. Required. - :vartype name: str - """ - - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name property. Required.""" - - @overload - def __init__( - self, - *, - name: str, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class SpreadRecordForNonDiscriminatedUnion(_model_base.Model): """The model spread Record. diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py index fcc6196e83c..02040315ef4 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/__init__.py @@ -40,7 +40,6 @@ from ._operations import ExtendsDifferentSpreadModelArrayOperations # type: ignore from ._operations import MultipleSpreadOperations # type: ignore from ._operations import SpreadRecordUnionOperations # type: ignore -from ._operations import SpreadRecordDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnionOperations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion2Operations # type: ignore from ._operations import SpreadRecordNonDiscriminatedUnion3Operations # type: ignore @@ -78,7 +77,6 @@ "ExtendsDifferentSpreadModelArrayOperations", "MultipleSpreadOperations", "SpreadRecordUnionOperations", - "SpreadRecordDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnionOperations", "SpreadRecordNonDiscriminatedUnion2Operations", "SpreadRecordNonDiscriminatedUnion3Operations", diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py index 3f8365188d3..cbacc93b633 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/operations/_operations.py @@ -831,34 +831,6 @@ def build_spread_record_union_put_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_spread_record_discriminated_union_get_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion" - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) - - -def build_spread_record_discriminated_union_put_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) - - def build_spread_record_non_discriminated_union_get_request( # pylint: disable=name-too-long **kwargs: Any, ) -> HttpRequest: @@ -5867,181 +5839,6 @@ def put( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore -class SpreadRecordDiscriminatedUnionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~typetest.property.additionalproperties.AdditionalPropertiesClient`'s - :attr:`spread_record_discriminated_union` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AdditionalPropertiesClientConfiguration = ( - input_args.pop(0) if input_args else kwargs.pop("config") - ) - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def get(self, **kwargs: Any) -> _models.SpreadRecordForDiscriminatedUnion: - """Get call. - - :return: SpreadRecordForDiscriminatedUnion. The SpreadRecordForDiscriminatedUnion is compatible - with MutableMapping - :rtype: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SpreadRecordForDiscriminatedUnion] = kwargs.pop("cls", None) - - _request = build_spread_record_discriminated_union_get_request( - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.SpreadRecordForDiscriminatedUnion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def put( - self, body: _models.SpreadRecordForDiscriminatedUnion, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - @overload - def put(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - @overload - def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None: - """Put operation. - - :param body: body. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - - def put( # pylint: disable=inconsistent-return-statements - self, body: Union[_models.SpreadRecordForDiscriminatedUnion, JSON, IO[bytes]], **kwargs: Any - ) -> None: - """Put operation. - - :param body: body. Is one of the following types: SpreadRecordForDiscriminatedUnion, JSON, - IO[bytes] Required. - :type body: ~typetest.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion or - JSON or IO[bytes] - :return: None - :rtype: None - :raises ~corehttp.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_spread_record_discriminated_union_put_request( - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - class SpreadRecordNonDiscriminatedUnionOperations: # pylint: disable=name-too-long """ .. warning:: diff --git a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py index 6b59188dc59..37db2f8fc34 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py @@ -118,7 +118,7 @@ async def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -145,10 +145,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_request( content_type=content_type, @@ -237,7 +237,7 @@ async def get(self, **kwargs: Any) -> bool: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.json()) + deserialized = _deserialize(bool, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -264,10 +264,10 @@ async def put(self, body: bool, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_boolean_put_request( content_type=content_type, @@ -475,7 +475,7 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -502,10 +502,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_type_request_body_request( content_type=content_type, @@ -638,7 +638,7 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -665,10 +665,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -828,10 +828,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_verify_verify_request( content_type=content_type, @@ -947,10 +947,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py index e23a42b8df8..496a09369c8 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py @@ -44,7 +44,7 @@ def build_string_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/string" @@ -71,7 +71,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: def build_boolean_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/boolean" @@ -125,7 +125,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: def build_decimal_type_response_body_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/decimal/response_body" @@ -166,7 +166,7 @@ def build_decimal_type_request_parameter_request( # pylint: disable=name-too-lo def build_decimal128_type_response_body_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/type/scalar/decimal128/response_body" @@ -321,7 +321,7 @@ def get(self, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -348,10 +348,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_string_put_request( content_type=content_type, @@ -440,7 +440,7 @@ def get(self, **kwargs: Any) -> bool: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.json()) + deserialized = _deserialize(bool, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -467,10 +467,10 @@ def put(self, body: bool, **kwargs: Any) -> None: # pylint: disable=inconsisten _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_boolean_put_request( content_type=content_type, @@ -678,7 +678,7 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -707,10 +707,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_type_request_body_request( content_type=content_type, @@ -845,7 +845,7 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.json()) + deserialized = _deserialize(decimal.Decimal, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -874,10 +874,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -1039,10 +1039,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal_verify_verify_request( content_type=content_type, @@ -1158,10 +1158,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index 159c58b5b19..2d19c6688bd 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -23,7 +22,7 @@ from corehttp.runtime.pipeline import PipelineResponse from corehttp.utils import case_insensitive_dict -from .._model_base import SdkJSONEncoder, _deserialize +from .._model_base import _deserialize from .._serialization import Serializer from .._vendor import ReturnTypeChangedFromClientMixinABC @@ -42,7 +41,7 @@ def build_return_type_changed_from_test_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: str = kwargs.pop("content_type") - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "text/plain") # Construct URL _url = "/test" @@ -76,10 +75,10 @@ def test(self, body: str, **kwargs: Any) -> str: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[str] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_return_type_changed_from_test_request( content_type=content_type, @@ -110,7 +109,7 @@ def test(self, body: str, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index 2c2aec7abd1..4372d5a4765 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -5,7 +5,6 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -23,7 +22,7 @@ from corehttp.runtime.pipeline import PipelineResponse from corehttp.utils import case_insensitive_dict -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import _deserialize from ..._operations._operations import build_return_type_changed_from_test_request from .._vendor import ReturnTypeChangedFromClientMixinABC @@ -57,10 +56,10 @@ async def test(self, body: str, **kwargs: Any) -> str: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) cls: ClsType[str] = kwargs.pop("cls", None) - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = body _request = build_return_type_changed_from_test_request( content_type=content_type, @@ -93,7 +92,7 @@ async def test(self, body: str, **kwargs: Any) -> str: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.json()) + deserialized = _deserialize(str, response.text()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore From 301ab6fbf5036434e1b2114b136317d11afe8bec Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 19 Mar 2025 05:42:22 +0000 Subject: [PATCH 3/9] Update dependencies (2025-03-19 05:42:22) --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 8311df3e63e..df03a548fa4 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index cef3b7f5c61..8aca2ec667f 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3695936eeb6..fdbf03263ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(xyfohv7glp6msr4ipudj2mb5ju) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1535,9 +1535,9 @@ packages: peerDependencies: '@typespec/compiler': ^0.67.1 - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz} - version: 0.8.0 + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz} + version: 0.8.1 engines: {node: '>=18.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.53.0 <1.0.0' @@ -6155,7 +6155,7 @@ snapshots: dependencies: '@typespec/compiler': 0.67.1(@types/node@22.5.5) - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(xyfohv7glp6msr4ipudj2mb5ju)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(nzqsibdudqbld3r7bpinzdupvm) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) @@ -6176,7 +6176,7 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2NjMyOS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.0.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(vsru7ipd7qt42slknz5aanwsou) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) From 93c14425d620f286bfa5f9a2ab19c37309182350 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 19 Mar 2025 05:46:38 +0000 Subject: [PATCH 4/9] Regenerate for typespec-python (2025-03-19 05:46:38) --- .../core/basic/_operations/_operations.py | 32 ++-- .../core/basic/aio/_operations/_operations.py | 4 +- .../lro/standard/_operations/_operations.py | 15 +- .../standard/aio/_operations/_operations.py | 2 +- .../core/page/aio/operations/_operations.py | 2 +- .../azure/core/page/operations/_operations.py | 30 ++-- .../core/traits/_operations/_operations.py | 9 +- .../traits/aio/_operations/_operations.py | 2 +- .../example/basic/_operations/_operations.py | 7 +- .../basic/aio/_operations/_operations.py | 2 +- .../aio/operations/_operations.py | 6 +- .../operations/_operations.py | 46 ++++-- .../aio/operations/_operations.py | 8 +- .../operations/_operations.py | 41 +++-- .../resources/aio/operations/_operations.py | 22 +-- .../resources/operations/_operations.py | 152 +++++++++++------- .../lro/rpc/_operations/_operations.py | 5 +- .../lro/rpc/aio/_operations/_operations.py | 2 +- .../client/structure/service/_client.py | 2 +- .../client/structure/service/aio/_client.py | 2 +- .../service/aio/operations/_operations.py | 18 +-- .../service/operations/_operations.py | 18 +-- .../client/structure/multiclient/_client.py | 4 +- .../multiclient/_operations/_operations.py | 12 +- .../structure/multiclient/aio/_client.py | 4 +- .../aio/_operations/_operations.py | 12 +- .../structure/renamedoperation/_client.py | 2 +- .../structure/renamedoperation/aio/_client.py | 2 +- .../aio/operations/_operations.py | 12 +- .../operations/_operations.py | 12 +- .../structure/twooperationgroup/_client.py | 2 +- .../twooperationgroup/aio/_client.py | 2 +- .../aio/operations/_operations.py | 12 +- .../operations/_operations.py | 12 +- .../resiliency/srv/driven1/_client.py | 20 ++- .../resiliency/srv/driven1/_configuration.py | 11 +- .../srv/driven1/_operations/_operations.py | 27 +++- .../resiliency/srv/driven1/aio/_client.py | 20 ++- .../srv/driven1/aio/_configuration.py | 11 +- .../driven1/aio/_operations/_operations.py | 27 +++- .../resiliency/srv/driven2/_client.py | 20 ++- .../resiliency/srv/driven2/_configuration.py | 11 +- .../srv/driven2/_operations/_operations.py | 36 ++++- .../resiliency/srv/driven2/aio/_client.py | 20 ++- .../srv/driven2/aio/_configuration.py | 11 +- .../driven2/aio/_operations/_operations.py | 36 ++++- .../server/path/multiple/_client.py | 16 +- .../server/path/multiple/_configuration.py | 12 +- .../path/multiple/_operations/_operations.py | 8 +- .../server/path/multiple/aio/_client.py | 16 +- .../path/multiple/aio/_configuration.py | 12 +- .../multiple/aio/_operations/_operations.py | 8 +- .../versioned/_operations/_operations.py | 15 +- .../versioning/added/_client.py | 2 +- .../versioning/added/aio/_client.py | 2 +- .../added/aio/operations/_operations.py | 6 +- .../added/operations/_operations.py | 6 +- .../versioning/madeoptional/_client.py | 2 +- .../madeoptional/_operations/_operations.py | 2 +- .../versioning/madeoptional/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- .../versioning/removed/_client.py | 2 +- .../removed/_operations/_operations.py | 4 +- .../versioning/removed/aio/_client.py | 2 +- .../removed/aio/_operations/_operations.py | 4 +- .../versioning/renamedfrom/_client.py | 2 +- .../versioning/renamedfrom/aio/_client.py | 2 +- .../renamedfrom/aio/operations/_operations.py | 4 +- .../renamedfrom/operations/_operations.py | 4 +- .../returntypechangedfrom/_client.py | 2 +- .../_operations/_operations.py | 2 +- .../returntypechangedfrom/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- .../versioning/typechangedfrom/_client.py | 2 +- .../_operations/_operations.py | 2 +- .../versioning/typechangedfrom/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- .../server/path/multiple/_client.py | 16 +- .../server/path/multiple/_configuration.py | 12 +- .../path/multiple/_operations/_operations.py | 8 +- .../server/path/multiple/aio/_client.py | 16 +- .../path/multiple/aio/_configuration.py | 12 +- .../multiple/aio/_operations/_operations.py | 8 +- .../versioned/_operations/_operations.py | 15 +- .../versioning/added/_client.py | 2 +- .../versioning/added/aio/_client.py | 2 +- .../added/aio/operations/_operations.py | 6 +- .../added/operations/_operations.py | 6 +- .../versioning/madeoptional/_client.py | 2 +- .../madeoptional/_operations/_operations.py | 2 +- .../versioning/madeoptional/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- .../versioning/removed/_client.py | 2 +- .../removed/_operations/_operations.py | 4 +- .../versioning/removed/aio/_client.py | 2 +- .../removed/aio/_operations/_operations.py | 4 +- .../versioning/renamedfrom/_client.py | 2 +- .../versioning/renamedfrom/aio/_client.py | 2 +- .../renamedfrom/aio/operations/_operations.py | 4 +- .../renamedfrom/operations/_operations.py | 4 +- .../returntypechangedfrom/_client.py | 2 +- .../_operations/_operations.py | 2 +- .../returntypechangedfrom/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- .../versioning/typechangedfrom/_client.py | 2 +- .../_operations/_operations.py | 2 +- .../versioning/typechangedfrom/aio/_client.py | 2 +- .../aio/_operations/_operations.py | 2 +- 108 files changed, 619 insertions(+), 448 deletions(-) diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py index 28fd837cb2d..f63c4cb6379 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py @@ -44,12 +44,13 @@ _SERIALIZER.client_side_validation = False -def build_basic_create_or_update_request(id: int, **kwargs: Any) -> HttpRequest: +def build_basic_create_or_update_request( + id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,12 +72,13 @@ def build_basic_create_or_update_request(id: int, **kwargs: Any) -> HttpRequest: return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_create_or_replace_request(id: int, **kwargs: Any) -> HttpRequest: +def build_basic_create_or_replace_request( + id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,11 +100,10 @@ def build_basic_create_or_replace_request(id: int, **kwargs: Any) -> HttpRequest return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_get_request(id: int, **kwargs: Any) -> HttpRequest: +def build_basic_get_request(id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,12 +132,12 @@ def build_basic_list_request( filter: Optional[str] = None, select: Optional[List[str]] = None, expand: Optional[List[str]] = None, + api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,11 +166,10 @@ def build_basic_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_delete_request(id: int, **kwargs: Any) -> HttpRequest: +def build_basic_delete_request(id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,11 +189,12 @@ def build_basic_delete_request(id: int, **kwargs: Any) -> HttpRequest: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_export_request(id: int, *, format: str, **kwargs: Any) -> HttpRequest: +def build_basic_export_request( + id: int, *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,11 +215,12 @@ def build_basic_export_request(id: int, *, format: str, **kwargs: Any) -> HttpRe return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_export_all_users_request(*, format: str, **kwargs: Any) -> HttpRequest: +def build_basic_export_all_users_request( + *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -334,8 +336,8 @@ def create_or_update(self, id: int, resource: Union[_models.User, JSON, IO[bytes _request = build_basic_create_or_update_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -469,8 +471,8 @@ def create_or_replace(self, id: int, resource: Union[_models.User, JSON, IO[byte _request = build_basic_create_or_replace_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py index 8142baeff57..423a76142b0 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py @@ -153,8 +153,8 @@ async def create_or_update( _request = build_basic_create_or_update_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -290,8 +290,8 @@ async def create_or_replace( _request = build_basic_create_or_replace_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py index 46281ebcfa9..5fae701c611 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py @@ -44,12 +44,13 @@ _SERIALIZER.client_side_validation = False -def build_standard_create_or_replace_request(name: str, **kwargs: Any) -> HttpRequest: +def build_standard_create_or_replace_request( + name: str, *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,11 +72,10 @@ def build_standard_create_or_replace_request(name: str, **kwargs: Any) -> HttpRe return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_standard_delete_request(name: str, **kwargs: Any) -> HttpRequest: +def build_standard_delete_request(name: str, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,11 +95,12 @@ def build_standard_delete_request(name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_standard_export_request(name: str, *, format: str, **kwargs: Any) -> HttpRequest: +def build_standard_export_request( + name: str, *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,8 +149,8 @@ def _create_or_replace_initial( _request = build_standard_create_or_replace_request( name=name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py index d4b2420ffa8..6aeb27d4078 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py @@ -74,8 +74,8 @@ async def _create_or_replace_initial( _request = build_standard_create_or_replace_request( name=name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py index 8e6733fd50a..857c4081c22 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py @@ -434,8 +434,8 @@ def prepare_request(next_link=None): _request = build_page_list_with_parameters_request( another=another, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py index c31207bd525..e5dfe73c258 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py @@ -45,12 +45,11 @@ def build_two_models_as_page_item_list_first_item_request( # pylint: disable=name-too-long - **kwargs: Any, + *, api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,12 +65,11 @@ def build_two_models_as_page_item_list_first_item_request( # pylint: disable=na def build_two_models_as_page_item_list_second_item_request( # pylint: disable=name-too-long - **kwargs: Any, + *, api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,11 +84,10 @@ def build_two_models_as_page_item_list_second_item_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_page_list_with_page_request(**kwargs: Any) -> HttpRequest: +def build_page_list_with_page_request(*, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,13 +103,15 @@ def build_page_list_with_page_request(**kwargs: Any) -> HttpRequest: def build_page_list_with_parameters_request( - *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, **kwargs: Any + *, + another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, + api_version: str = "2022-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,11 +130,12 @@ def build_page_list_with_parameters_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_page_list_with_custom_page_model_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_page_list_with_custom_page_model_request( # pylint: disable=name-too-long + *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +425,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any, + **kwargs: Any ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -449,7 +449,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any, + **kwargs: Any ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -473,7 +473,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any, + **kwargs: Any ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -496,7 +496,7 @@ def list_with_parameters( body_input: Union[_models.ListItemInputBody, JSON, IO[bytes]], *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, - **kwargs: Any, + **kwargs: Any ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -535,8 +535,8 @@ def prepare_request(next_link=None): _request = build_page_list_with_parameters_request( another=another, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py index bbb6ea903a3..5b3a1b965c8 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py @@ -54,12 +54,12 @@ def build_traits_smoke_test_request( if_modified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, + api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,12 +90,13 @@ def build_traits_smoke_test_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_traits_repeatable_action_request(id: int, **kwargs: Any) -> HttpRequest: +def build_traits_repeatable_action_request( + id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,8 +319,8 @@ def repeatable_action( _request = build_traits_repeatable_action_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py index 0cdec372bb8..d36b4abdbf8 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py @@ -238,8 +238,8 @@ async def repeatable_action( _request = build_traits_repeatable_action_request( id=id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py index 0e8f98efa24..17908c42403 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py @@ -42,12 +42,13 @@ _SERIALIZER.client_side_validation = False -def build_azure_example_basic_action_request(*, query_param: str, header_param: str, **kwargs: Any) -> HttpRequest: +def build_azure_example_basic_action_request( + *, query_param: str, header_param: str, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,8 +181,8 @@ def basic_action( _request = build_azure_example_basic_action_request( query_param=query_param, header_param=header_param, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py index 475464cd1bb..0114696dc45 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py @@ -154,8 +154,8 @@ async def basic_action( _request = build_azure_example_basic_action_request( query_param=query_param, header_param=header_param, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py index 0784ca748f6..61761fa1dfc 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py @@ -267,8 +267,8 @@ async def create_with_system_assigned( resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -438,8 +438,8 @@ async def update_with_user_assigned_and_system_assigned( # pylint: disable=name resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -691,8 +691,8 @@ async def create_for_user_defined_error( resource_group_name=resource_group_name, confidential_resource_name=confidential_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py index 2e32ebb6d62..c9e7e48dd0c 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py @@ -46,12 +46,16 @@ def build_managed_identity_get_request( - resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + managed_identity_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,13 +80,17 @@ def build_managed_identity_get_request( def build_managed_identity_create_with_system_assigned_request( # pylint: disable=name-too-long - resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + managed_identity_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,13 +117,17 @@ def build_managed_identity_create_with_system_assigned_request( # pylint: disab def build_managed_identity_update_with_user_assigned_and_system_assigned_request( # pylint: disable=name-too-long - resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + managed_identity_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -142,12 +154,16 @@ def build_managed_identity_update_with_user_assigned_and_system_assigned_request def build_error_get_for_predefined_error_request( # pylint: disable=name-too-long - resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + confidential_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,13 +186,17 @@ def build_error_get_for_predefined_error_request( # pylint: disable=name-too-lo def build_error_create_for_user_defined_error_request( # pylint: disable=name-too-long - resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + confidential_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -419,8 +439,8 @@ def create_with_system_assigned( resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -590,8 +610,8 @@ def update_with_user_assigned_and_system_assigned( # pylint: disable=name-too-l resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -843,8 +863,8 @@ def create_for_user_defined_error( resource_group_name=resource_group_name, confidential_resource_name=confidential_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py index d93d71dc040..057d8550cf9 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py @@ -263,8 +263,8 @@ async def check_global( _request = build_check_name_availability_check_global_request( subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -404,8 +404,8 @@ async def check_local( _request = build_check_name_availability_check_local_request( location=location, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -488,8 +488,8 @@ async def _create_or_replace_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -720,8 +720,8 @@ async def _export_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py index 124f552c529..e5f533d37f8 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py @@ -49,11 +49,10 @@ _SERIALIZER.client_side_validation = False -def build_operations_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(*, api_version: str = "2023-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,13 +68,12 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: def build_check_name_availability_check_global_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any + subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,13 +96,12 @@ def build_check_name_availability_check_global_request( # pylint: disable=name- def build_check_name_availability_check_local_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any + location: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,13 +125,17 @@ def build_check_name_availability_check_local_request( # pylint: disable=name-t def build_lro_create_or_replace_request( - resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + order_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,13 +160,17 @@ def build_lro_create_or_replace_request( def build_lro_export_request( - resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + order_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,12 +195,16 @@ def build_lro_export_request( def build_lro_delete_request( - resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + order_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,8 +434,8 @@ def check_global( _request = build_check_name_availability_check_global_request( subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -566,8 +575,8 @@ def check_local( _request = build_check_name_availability_check_local_request( location=location, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -650,8 +659,8 @@ def _create_or_replace_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -878,8 +887,8 @@ def _export_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py index 23941e40e61..a8a585b1d1a 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py @@ -192,8 +192,8 @@ async def _create_or_replace_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -429,8 +429,8 @@ async def _update_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1052,8 +1052,8 @@ async def action_sync( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1205,8 +1205,8 @@ async def _create_or_replace_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1457,8 +1457,8 @@ async def _update_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2007,8 +2007,8 @@ async def _create_or_update_initial( _request = build_singleton_create_or_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2299,8 +2299,8 @@ async def update( _request = build_singleton_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2542,8 +2542,8 @@ async def _create_or_update_initial( _request = build_extensions_resources_create_or_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2874,8 +2874,8 @@ async def update( _request = build_extensions_resources_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -3260,8 +3260,8 @@ async def create_or_update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -3422,8 +3422,8 @@ async def update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py index 5932659b7c6..0c9054ad499 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py @@ -50,12 +50,16 @@ def build_top_level_get_request( - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,13 +84,17 @@ def build_top_level_get_request( def build_top_level_create_or_replace_request( # pylint: disable=name-too-long - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,13 +121,17 @@ def build_top_level_create_or_replace_request( # pylint: disable=name-too-long def build_top_level_update_request( - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,12 +158,16 @@ def build_top_level_update_request( def build_top_level_delete_request( - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,12 +192,11 @@ def build_top_level_delete_request( def build_top_level_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,12 +218,11 @@ def build_top_level_list_by_resource_group_request( # pylint: disable=name-too- def build_top_level_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any + subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,13 +243,17 @@ def build_top_level_list_by_subscription_request( # pylint: disable=name-too-lo def build_top_level_action_sync_request( - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,12 +284,13 @@ def build_nested_get_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, + *, + api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -301,13 +320,14 @@ def build_nested_create_or_replace_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, + *, + api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -339,13 +359,14 @@ def build_nested_update_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, + *, + api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -377,12 +398,13 @@ def build_nested_delete_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, + *, + api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -408,12 +430,16 @@ def build_nested_delete_request( def build_nested_list_by_top_level_tracked_resource_request( # pylint: disable=name-too-long - resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + top_level_tracked_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -438,12 +464,11 @@ def build_nested_list_by_top_level_tracked_resource_request( # pylint: disable= def build_singleton_get_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -465,13 +490,12 @@ def build_singleton_get_by_resource_group_request( # pylint: disable=name-too-l def build_singleton_create_or_update_request( - resource_group_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -494,12 +518,13 @@ def build_singleton_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_singleton_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_singleton_update_request( + resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -523,12 +548,11 @@ def build_singleton_update_request(resource_group_name: str, subscription_id: st def build_singleton_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -550,12 +574,11 @@ def build_singleton_list_by_resource_group_request( # pylint: disable=name-too- def build_extensions_resources_get_request( - resource_uri: str, extensions_resource_name: str, **kwargs: Any + resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -577,13 +600,12 @@ def build_extensions_resources_get_request( def build_extensions_resources_create_or_update_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, **kwargs: Any + resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -607,13 +629,12 @@ def build_extensions_resources_create_or_update_request( # pylint: disable=name def build_extensions_resources_update_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, **kwargs: Any + resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -637,12 +658,11 @@ def build_extensions_resources_update_request( # pylint: disable=name-too-long def build_extensions_resources_delete_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, **kwargs: Any + resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -664,12 +684,11 @@ def build_extensions_resources_delete_request( # pylint: disable=name-too-long def build_extensions_resources_list_by_scope_request( # pylint: disable=name-too-long - resource_uri: str, **kwargs: Any + resource_uri: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -690,12 +709,16 @@ def build_extensions_resources_list_by_scope_request( # pylint: disable=name-to def build_location_resources_get_request( - location: str, location_resource_name: str, subscription_id: str, **kwargs: Any + location: str, + location_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -718,13 +741,17 @@ def build_location_resources_get_request( def build_location_resources_create_or_update_request( # pylint: disable=name-too-long - location: str, location_resource_name: str, subscription_id: str, **kwargs: Any + location: str, + location_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -749,13 +776,17 @@ def build_location_resources_create_or_update_request( # pylint: disable=name-t def build_location_resources_update_request( - location: str, location_resource_name: str, subscription_id: str, **kwargs: Any + location: str, + location_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -780,12 +811,16 @@ def build_location_resources_update_request( def build_location_resources_delete_request( - location: str, location_resource_name: str, subscription_id: str, **kwargs: Any + location: str, + location_resource_name: str, + subscription_id: str, + *, + api_version: str = "2023-12-01-preview", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -808,12 +843,11 @@ def build_location_resources_delete_request( def build_location_resources_list_by_location_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any + location: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -951,8 +985,8 @@ def _create_or_replace_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1188,8 +1222,8 @@ def _update_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1811,8 +1845,8 @@ def action_sync( # pylint: disable=inconsistent-return-statements resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -1964,8 +1998,8 @@ def _create_or_replace_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2216,8 +2250,8 @@ def _update_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -2766,8 +2800,8 @@ def _create_or_update_initial( _request = build_singleton_create_or_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -3058,8 +3092,8 @@ def update( _request = build_singleton_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -3301,8 +3335,8 @@ def _create_or_update_initial( _request = build_extensions_resources_create_or_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -3633,8 +3667,8 @@ def update( _request = build_extensions_resources_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -4021,8 +4055,8 @@ def create_or_update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, @@ -4183,8 +4217,8 @@ def update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py index 3e3fd504125..b8f0c7007ce 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py @@ -44,12 +44,11 @@ _SERIALIZER.client_side_validation = False -def build_rpc_long_running_rpc_request(**kwargs: Any) -> HttpRequest: +def build_rpc_long_running_rpc_request(*, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,8 +92,8 @@ def _long_running_rpc_initial( _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_rpc_long_running_rpc_request( - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py index 0dfcbc34b98..7d34bf7cc24 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py @@ -69,8 +69,8 @@ async def _long_running_rpc_initial( _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_rpc_long_running_rpc_request( - content_type=content_type, api_version=self._config.api_version, + content_type=content_type, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_client.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_client.py index 14f4ad71030..4fad455bba6 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_client.py @@ -101,7 +101,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/_client.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/_client.py index a59b3a26d57..792f233d291 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/_client.py @@ -103,7 +103,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py index 88bf08cc6a1..7e2ca244d83 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py @@ -111,7 +111,7 @@ async def eight(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -174,7 +174,7 @@ async def three(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -219,7 +219,7 @@ async def four(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -282,7 +282,7 @@ async def five(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -327,7 +327,7 @@ async def six(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -375,7 +375,7 @@ async def one(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -420,7 +420,7 @@ async def two(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -483,7 +483,7 @@ async def seven(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -546,7 +546,7 @@ async def nine(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/operations/_operations.py index 5dc8e031ea2..b92328ed27d 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/operations/_operations.py @@ -165,7 +165,7 @@ def eight(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-s ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -228,7 +228,7 @@ def three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-s ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -273,7 +273,7 @@ def four(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -336,7 +336,7 @@ def five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -381,7 +381,7 @@ def six(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -429,7 +429,7 @@ def one(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -474,7 +474,7 @@ def two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -537,7 +537,7 @@ def seven(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-s ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -600,7 +600,7 @@ def nine(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_client.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_client.py index 2681305999d..1c7673e5115 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_client.py @@ -81,7 +81,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) @@ -159,7 +159,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_operations/_operations.py index 14365ddb794..f66a3698bdf 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_operations/_operations.py @@ -105,7 +105,7 @@ def renamed_one(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -150,7 +150,7 @@ def renamed_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -195,7 +195,7 @@ def renamed_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -243,7 +243,7 @@ def renamed_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -288,7 +288,7 @@ def renamed_four(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -333,7 +333,7 @@ def renamed_six(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_client.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_client.py index 6640b7863be..ef659c7df10 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_client.py @@ -83,7 +83,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) @@ -163,7 +163,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py index e0023216b21..c0edfb70723 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py @@ -68,7 +68,7 @@ async def renamed_one(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -113,7 +113,7 @@ async def renamed_three(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -158,7 +158,7 @@ async def renamed_five(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -206,7 +206,7 @@ async def renamed_two(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -251,7 +251,7 @@ async def renamed_four(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -296,7 +296,7 @@ async def renamed_six(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_client.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_client.py index 6a411e8163d..ff5fac61c22 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_client.py @@ -86,7 +86,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/_client.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/_client.py index e85841eba7f..f702528787e 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/_client.py @@ -88,7 +88,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py index febc5847535..eeb9ef07d17 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py @@ -86,7 +86,7 @@ async def renamed_two(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -131,7 +131,7 @@ async def renamed_four(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -176,7 +176,7 @@ async def renamed_six(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -224,7 +224,7 @@ async def renamed_one(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -269,7 +269,7 @@ async def renamed_three(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -314,7 +314,7 @@ async def renamed_five(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/operations/_operations.py index efbf4490998..1e17805b193 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/operations/_operations.py @@ -122,7 +122,7 @@ def renamed_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -167,7 +167,7 @@ def renamed_four(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -212,7 +212,7 @@ def renamed_six(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -260,7 +260,7 @@ def renamed_one(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-re ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -305,7 +305,7 @@ def renamed_three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -350,7 +350,7 @@ def renamed_five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-r ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_client.py b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_client.py index fae7146457f..9fef187a12b 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_client.py @@ -87,7 +87,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/_client.py b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/_client.py index e112844aae6..0f0edd5d0ab 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/_client.py @@ -89,7 +89,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/operations/_operations.py index 85c29d50167..a73fb53cb1f 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/aio/operations/_operations.py @@ -84,7 +84,7 @@ async def one(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -129,7 +129,7 @@ async def three(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -174,7 +174,7 @@ async def four(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -237,7 +237,7 @@ async def two(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -282,7 +282,7 @@ async def five(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -327,7 +327,7 @@ async def six(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/operations/_operations.py index f9120decf27..0aad10057c9 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/operations/_operations.py @@ -121,7 +121,7 @@ def one(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -166,7 +166,7 @@ def three(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-s ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -211,7 +211,7 @@ def four(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -274,7 +274,7 @@ def two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -319,7 +319,7 @@ def five(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-st ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -364,7 +364,7 @@ def six(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-sta ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "client": self._serialize.url("self._config.client", self._config.client, "str"), + "client": self._serialize.url("self._config.client", self._config.client, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py index 039cabdc3e7..906d7f0c1e5 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py @@ -19,7 +19,9 @@ from ._serialization import Deserializer, Serializer -class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): +class ResiliencyServiceDrivenClient( + ResiliencyServiceDrivenClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -31,19 +33,18 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default - value is "v1". Note that overriding this default value may result in unsupported behavior. + up in the next deployment to be both 'v1' and 'v2'. Default value is "v1". :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, **kwargs: Any + self, endpoint: str, service_deployment_version: str, *, api_version: str = "v1", **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -90,9 +91,14 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py index e4da6df9461..0f7bdfbad4b 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py @@ -26,15 +26,12 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default - value is "v1". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :param api_version: Pass in 'v1'. This represents the API version of the service. Will grow up + in the next deployment to be both 'v1' and 'v2'. Default value is "v1". + :type api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1") - + def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v1", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_operations/_operations.py index 28098527c83..622b400ec23 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_operations/_operations.py @@ -104,9 +104,14 @@ def from_none(self, **kwargs: Any) -> bool: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -159,9 +164,14 @@ def from_one_required( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -213,9 +223,14 @@ def from_one_optional( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py index abfab7249ea..fe3de4f6be1 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py @@ -19,7 +19,9 @@ from ._operations import ResiliencyServiceDrivenClientOperationsMixin -class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): +class ResiliencyServiceDrivenClient( + ResiliencyServiceDrivenClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -31,19 +33,18 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default - value is "v1". Note that overriding this default value may result in unsupported behavior. + up in the next deployment to be both 'v1' and 'v2'. Default value is "v1". :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, **kwargs: Any + self, endpoint: str, service_deployment_version: str, *, api_version: str = "v1", **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -92,9 +93,14 @@ def send_request( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py index 8fc2b09c37f..407ce9f4e79 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py @@ -26,15 +26,12 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default - value is "v1". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :param api_version: Pass in 'v1'. This represents the API version of the service. Will grow up + in the next deployment to be both 'v1' and 'v2'. Default value is "v1". + :type api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1") - + def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v1", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py index c87f95293c7..8917461e63f 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py @@ -69,9 +69,14 @@ async def from_none(self, **kwargs: Any) -> bool: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -122,9 +127,14 @@ async def from_one_required(self, *, parameter: str, **kwargs: Any) -> None: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -174,9 +184,14 @@ async def from_one_optional(self, *, parameter: Optional[str] = None, **kwargs: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py index a871e6cacac..cec65486da4 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py @@ -19,7 +19,9 @@ from ._serialization import Deserializer, Serializer -class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): +class ResiliencyServiceDrivenClient( + ResiliencyServiceDrivenClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -48,19 +50,18 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Known values are "v2" and None. Default value is "v2". Note that overriding this - default value may result in unsupported behavior. + service. Default value is "v2". :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, **kwargs: Any + self, endpoint: str, service_deployment_version: str, *, api_version: str = "v2", **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -107,9 +108,14 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py index 5a153640f3a..f561d533821 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py @@ -26,15 +26,12 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Known values are "v2" and None. Default value is "v2". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param api_version: Pass in either 'v1' or 'v2'. This represents the API version of a service. + Default value is "v2". + :type api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v2") - + def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v2", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_operations/_operations.py index a5a693c8843..3e3a69c9071 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_operations/_operations.py @@ -128,9 +128,14 @@ def add_operation(self, **kwargs: Any) -> None: # pylint: disable=inconsistent- path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -182,9 +187,14 @@ def from_none(self, *, new_parameter: Optional[str] = None, **kwargs: Any) -> bo path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -243,9 +253,14 @@ def from_one_required( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -303,9 +318,14 @@ def from_one_optional( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py index 3a3d067be58..e9d8d36b681 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py @@ -19,7 +19,9 @@ from ._operations import ResiliencyServiceDrivenClientOperationsMixin -class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): +class ResiliencyServiceDrivenClient( + ResiliencyServiceDrivenClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -48,19 +50,18 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Known values are "v2" and None. Default value is "v2". Note that overriding this - default value may result in unsupported behavior. + service. Default value is "v2". :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, **kwargs: Any + self, endpoint: str, service_deployment_version: str, *, api_version: str = "v2", **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: @@ -109,9 +110,14 @@ def send_request( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py index bd35e1c0c81..d83aff6b69b 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py @@ -26,15 +26,12 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Known values are "v2" and None. Default value is "v2". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param api_version: Pass in either 'v1' or 'v2'. This represents the API version of a service. + Default value is "v2". + :type api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v2") - + def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v2", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py index e36e4fa5fb9..427ca714d50 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py @@ -73,9 +73,14 @@ async def add_operation(self, **kwargs: Any) -> None: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -127,9 +132,14 @@ async def from_none(self, *, new_parameter: Optional[str] = None, **kwargs: Any) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -186,9 +196,14 @@ async def from_one_required(self, *, parameter: str, new_parameter: Optional[str path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -246,9 +261,14 @@ async def from_one_optional( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), "serviceDeploymentVersion": self._serialize.url( - "self._config.service_deployment_version", self._config.service_deployment_version, "str" + "self._config.service_deployment_version", + self._config.service_deployment_version, + "str", + skip_quote=True, + ), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True ), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py index 2d3945dd42c..7f879513435 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py @@ -7,34 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any +from typing import Any, Union from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from . import models as _models from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin from ._serialization import Deserializer, Serializer -class MultipleClient(MultipleClientOperationsMixin): +class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, **kwargs: Any + self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -79,7 +79,9 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py index 1a84717b685..9e17c72d27e 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py @@ -6,10 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, Union from azure.core.pipeline import policies +from . import models as _models from ._version import VERSION @@ -22,14 +23,11 @@ class MultipleClientConfiguration: # pylint: disable=too-many-instance-attribut :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str or ~server.path.multiple.models.Versions + :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :type api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.0") - + def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_operations/_operations.py index 0ac655cc39d..881fc5998f7 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_operations/_operations.py @@ -84,7 +84,9 @@ def no_operation_params(self, **kwargs: Any) -> None: # pylint: disable=inconsi ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -134,7 +136,9 @@ def with_operation_path_param( # pylint: disable=inconsistent-return-statements ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py index 10c4a7214a5..f9f091b603c 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py @@ -7,34 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable +from typing import Any, Awaitable, Union from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin -class MultipleClient(MultipleClientOperationsMixin): +class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, **kwargs: Any + self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -81,7 +81,9 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py index ae9ecd544b7..663d0aa363e 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py @@ -6,10 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, Union from azure.core.pipeline import policies +from .. import models as _models from .._version import VERSION @@ -22,14 +23,11 @@ class MultipleClientConfiguration: # pylint: disable=too-many-instance-attribut :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str or ~server.path.multiple.models.Versions + :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :type api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.0") - + def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py index 9e6a92fdfce..609cde2af22 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py @@ -64,7 +64,9 @@ async def no_operation_params(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -112,7 +114,9 @@ async def with_operation_path_param(self, keyword: str, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py index 5cf481a18b1..87d1db4878e 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py @@ -42,10 +42,11 @@ def build_versioned_without_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_versioned_with_query_api_version_request( # pylint: disable=name-too-long + *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-api-version" @@ -55,8 +56,9 @@ def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - api_version: str = kwargs.pop("api_version", "2022-12-01-preview") +def build_versioned_with_path_api_version_request( # pylint: disable=name-too-long + api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: # Construct URL _url = "/server/versions/versioned/with-path-api-version/{apiVersion}" path_format_arguments = { @@ -68,10 +70,11 @@ def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_old_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_versioned_with_query_old_api_version_request( # pylint: disable=name-too-long + *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-old-api-version" diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_client.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_client.py index 40e4a87f401..688be8aa114 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_client.py @@ -83,7 +83,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/_client.py index 580b735bdd2..4ef75f74694 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/_client.py @@ -85,7 +85,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py index ee609fd604b..791d8fb4451 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py @@ -156,7 +156,7 @@ async def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -290,7 +290,7 @@ async def v1( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -407,7 +407,7 @@ async def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/operations/_operations.py index eb4b74f3de3..b2ac8f9d843 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/operations/_operations.py @@ -203,7 +203,7 @@ def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwarg ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -335,7 +335,7 @@ def v1(self, body: Union[_models.ModelV1, JSON, IO[bytes]], *, header_v2: str, * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -450,7 +450,7 @@ def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) -> _m ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_client.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_client.py index ac0bf0a076d..162057496f4 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_client.py @@ -80,7 +80,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py index cf583ed9bee..26a43bd23f7 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py @@ -169,7 +169,7 @@ def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py index 07ea9a02f88..cd956109823 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py @@ -82,7 +82,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py index e59f4897cdf..3bce0232f6f 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py @@ -145,7 +145,7 @@ async def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_client.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_client.py index 39ad8c17e39..4589655bfcb 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_client.py @@ -80,7 +80,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_operations/_operations.py index b0385017472..d67fab5ab7b 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_operations/_operations.py @@ -159,7 +159,7 @@ def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) -> _m ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -276,7 +276,7 @@ def model_v3(self, body: Union[_models.ModelV3, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_client.py index 65407459b1e..535a848919c 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_client.py @@ -82,7 +82,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py index d1fd773d544..6ac80bbc327 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py @@ -125,7 +125,7 @@ async def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -244,7 +244,7 @@ async def model_v3(self, body: Union[_models.ModelV3, JSON, IO[bytes]], **kwargs ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py index c0dd5d0b32e..0d4d02c3d7d 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py @@ -83,7 +83,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py index c8264d9ae70..a1f54c2055d 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py @@ -85,7 +85,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py index 3ec4aef9bb3..dd9e9017ab6 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py @@ -152,7 +152,7 @@ async def new_op_in_new_interface( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -283,7 +283,7 @@ async def new_op( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py index 9041afcbb9f..8ed21322437 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py @@ -188,7 +188,7 @@ def new_op_in_new_interface( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -319,7 +319,7 @@ def new_op( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py index 84b6e6c87d8..8196ca24e68 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py @@ -82,7 +82,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index 23f9a67abb7..213f6a1617b 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -90,7 +90,7 @@ def test(self, body: str, **kwargs: Any) -> str: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py index 9189be8e3dd..34fe79c9039 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py @@ -84,7 +84,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index 7ce1477e2c7..d8ef8e196ea 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -72,7 +72,7 @@ async def test(self, body: str, **kwargs: Any) -> str: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py index c66041becc2..c4924b118aa 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py @@ -80,7 +80,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py index 4a5c3ce2574..597adc56799 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py @@ -161,7 +161,7 @@ def test(self, body: Union[_models.TestModel, JSON, IO[bytes]], *, param: str, * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py index eb6a347b764..947d88ba6d5 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py @@ -82,7 +82,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py index facba2f832c..e962f0261d2 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py @@ -140,7 +140,7 @@ async def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py index 86f9a5429a9..5ddec361988 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py @@ -7,33 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any +from typing import Any, Union from typing_extensions import Self from corehttp.rest import HttpRequest, HttpResponse from corehttp.runtime import PipelineClient, policies +from . import models as _models from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin from ._serialization import Deserializer, Serializer -class MultipleClient(MultipleClientOperationsMixin): +class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, **kwargs: Any + self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -72,7 +72,9 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py index 8ef145f24be..1672af351fb 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py @@ -6,10 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, Union from corehttp.runtime import policies +from . import models as _models from ._version import VERSION @@ -22,14 +23,11 @@ class MultipleClientConfiguration: :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str or ~server.path.multiple.models.Versions + :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :type api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.0") - + def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_operations/_operations.py index 32cc0a7c1a4..05c744f951d 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_operations/_operations.py @@ -82,7 +82,9 @@ def no_operation_params(self, **kwargs: Any) -> None: # pylint: disable=inconsi ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -129,7 +131,9 @@ def with_operation_path_param( # pylint: disable=inconsistent-return-statements ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py index ed38270cfc8..4256b19b695 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py @@ -7,33 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable +from typing import Any, Awaitable, Union from typing_extensions import Self from corehttp.rest import AsyncHttpResponse, HttpRequest from corehttp.runtime import AsyncPipelineClient, policies +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin -class MultipleClient(MultipleClientOperationsMixin): +class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, **kwargs: Any + self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -74,7 +74,9 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py index 9f71c626ed6..44ecbfe0751 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py @@ -6,10 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, Union from corehttp.runtime import policies +from .. import models as _models from .._version import VERSION @@ -22,14 +23,11 @@ class MultipleClientConfiguration: :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default - value is "v1.0". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str or ~server.path.multiple.models.Versions + :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :type api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.0") - + def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py index 810f3874cc2..5cf249786b2 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py @@ -61,7 +61,9 @@ async def no_operation_params(self, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -108,7 +110,9 @@ async def with_operation_path_param(self, keyword: str, **kwargs: Any) -> None: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + "apiVersion": self._serialize.url( + "self._config.api_version", self._config.api_version, "str", skip_quote=True + ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py index 9bf92afaeae..188e0549d4d 100644 --- a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py @@ -41,10 +41,11 @@ def build_versioned_without_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_versioned_with_query_api_version_request( # pylint: disable=name-too-long + *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-api-version" @@ -54,8 +55,9 @@ def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - api_version: str = kwargs.pop("api_version", "2022-12-01-preview") +def build_versioned_with_path_api_version_request( # pylint: disable=name-too-long + api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: # Construct URL _url = "/server/versions/versioned/with-path-api-version/{apiVersion}" path_format_arguments = { @@ -67,10 +69,11 @@ def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_old_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_versioned_with_query_old_api_version_request( # pylint: disable=name-too-long + *, api_version: str = "2022-12-01-preview", **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-old-api-version" diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_client.py index f914ba5a44b..f2b418cb320 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_client.py @@ -76,7 +76,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/_client.py index fe25a536f26..e5fd7466995 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/_client.py @@ -78,7 +78,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/operations/_operations.py index bc132e61606..ccf20198adc 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/aio/operations/_operations.py @@ -153,7 +153,7 @@ async def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -284,7 +284,7 @@ async def v1( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -400,7 +400,7 @@ async def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/operations/_operations.py index 826698f73f4..06c7313138d 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/operations/_operations.py @@ -201,7 +201,7 @@ def v2_in_interface(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwarg ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -330,7 +330,7 @@ def v1(self, body: Union[_models.ModelV1, JSON, IO[bytes]], *, header_v2: str, * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -442,7 +442,7 @@ def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) -> _m ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_client.py index 10461fb6738..98ade442caf 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_client.py @@ -73,7 +73,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py index d8af3a7af1b..2ba70d84934 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_operations/_operations.py @@ -167,7 +167,7 @@ def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py index 86f75694df7..6b9e804804e 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_client.py @@ -75,7 +75,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py index 62c3db5c2dc..3a5317d570b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py @@ -142,7 +142,7 @@ async def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_client.py index 88fe6c969f9..c1ea430aebc 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_client.py @@ -73,7 +73,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_operations/_operations.py index ca9df9d52fa..0fb89f55d58 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_operations/_operations.py @@ -157,7 +157,7 @@ def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) -> _m ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -271,7 +271,7 @@ def model_v3(self, body: Union[_models.ModelV3, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_client.py index 2403ce5bf1b..be0be34fa17 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_client.py @@ -75,7 +75,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py index c83c3b30b5b..6164482c641 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py @@ -122,7 +122,7 @@ async def v2(self, body: Union[_models.ModelV2, JSON, IO[bytes]], **kwargs: Any) ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -240,7 +240,7 @@ async def model_v3(self, body: Union[_models.ModelV3, JSON, IO[bytes]], **kwargs ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py index 7d6760e29b8..7af39e687db 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_client.py @@ -76,7 +76,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py index c15061f9564..fa119e17f59 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/_client.py @@ -78,7 +78,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py index 3594f937107..85920377275 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py @@ -149,7 +149,7 @@ async def new_op_in_new_interface( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -277,7 +277,7 @@ async def new_op( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py index 390e5c1a18f..80afd64c56b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/operations/_operations.py @@ -186,7 +186,7 @@ def new_op_in_new_interface( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -314,7 +314,7 @@ def new_op( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py index bc926299646..2457c456881 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_client.py @@ -75,7 +75,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index 2d19c6688bd..0b8b9bcc6ff 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -88,7 +88,7 @@ def test(self, body: str, **kwargs: Any) -> str: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py index 190a8403426..be63bbbf48c 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_client.py @@ -77,7 +77,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index 4372d5a4765..f038487ade4 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -69,7 +69,7 @@ async def test(self, body: str, **kwargs: Any) -> str: ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py index f2205ab553c..b00a7f1394a 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_client.py @@ -73,7 +73,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py index 2f348efba95..d3cf83667a2 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_operations/_operations.py @@ -159,7 +159,7 @@ def test(self, body: Union[_models.TestModel, JSON, IO[bytes]], *, param: str, * ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py index 39c1e3d27df..98998f70984 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_client.py @@ -75,7 +75,7 @@ def send_request( request_copy = deepcopy(request) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py index 987c7293bcf..d3d4d43245b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py @@ -137,7 +137,7 @@ async def test( ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "version": self._serialize.url("self._config.version", self._config.version, "str"), + "version": self._serialize.url("self._config.version", self._config.version, "str", skip_quote=True), } _request.url = self._client.format_url(_request.url, **path_format_arguments) From 88cc259c2ae5c26e92a4695c11ff8b42d465819c Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Mar 2025 14:36:48 +0800 Subject: [PATCH 5/9] update test --- .../asynctests/test_azure_arm_operationtemplates_async.py | 1 + .../mock_api_tests/test_azure_arm_operationtemplates.py | 1 + .../asynctests/test_encode_bytes_async.py | 7 ++++--- .../asynctests/test_parameters_collection_format_async.py | 6 ------ .../test_typetest_property_additionalproperties_async.py | 1 + .../test/generic_mock_api_tests/test_encode_bytes.py | 7 ++++--- .../test_parameters_collection_format.py | 4 ---- .../test_typetest_property_additionalproperties.py | 1 + 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py index bb6f807e44c..df4e1f6246e 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py @@ -18,6 +18,7 @@ async def client(credential, authentication_policy): SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy, + polling_interval=0, ) as client: yield client diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py index 4a2ca1309b5..d0e73ad772a 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py @@ -18,6 +18,7 @@ def client(credential, authentication_policy): SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy, + polling_interval=0, ) as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py index db7c3a30db7..912deb17828 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py @@ -107,7 +107,7 @@ def png_data() -> bytes: @pytest.mark.asyncio async def test_request_body(client: BytesClient, png_data: bytes): await client.request_body.default( - value=bytes("test", "utf-8"), + value=png_data, ) await client.request_body.octet_stream( value=png_data, @@ -126,8 +126,9 @@ async def test_request_body(client: BytesClient, png_data: bytes): @pytest.mark.asyncio async def test_response_body(client: BytesClient, png_data: bytes): expected = b"test" - assert expected == await client.response_body.default() + assert b"".join([d async for d in (await client.response_body.default())]) == png_data assert expected == await client.response_body.base64() - assert expected == await client.response_body.base64_url() assert b"".join([d async for d in (await client.response_body.octet_stream())]) == png_data assert b"".join([d async for d in (await client.response_body.custom_content_type())]) == png_data + # will reopen after TCGC release a fix version for https://github.com/Azure/typespec-azure/pull/2411 + # assert expected == await client.response_body.base64_url() diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py index b57a24eb4ce..c3ae9698079 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py @@ -33,12 +33,6 @@ async def test_query_ssv(client: CollectionFormatClient): await client.query.ssv(colors=["blue", "red", "green"]) -@pytest.mark.asyncio -@pytest.mark.skip(reason="https://github.com/aio-libs/aiohttp/issues/5904") -async def test_query_tsv(client: CollectionFormatClient): - await client.query.tsv(colors=["blue", "red", "green"]) - - @pytest.mark.asyncio async def test_csv_header(client: CollectionFormatClient): await client.header.csv(colors=["blue", "red", "green"]) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py index bd773f6a474..2109ea31791 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py @@ -262,6 +262,7 @@ async def test_spread_model_array(client: AdditionalPropertiesClient): await client.spread_model_array.put(body) +@pytest.mark.skip(reason="https://github.com/microsoft/typespec/pull/6425") @pytest.mark.asyncio async def test_spread_record_discriminated_union(client: AdditionalPropertiesClient): body = { diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_encode_bytes.py b/packages/typespec-python/test/generic_mock_api_tests/test_encode_bytes.py index b398952f6f8..7ed61a70b85 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_encode_bytes.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_encode_bytes.py @@ -103,7 +103,7 @@ def png_data() -> bytes: def test_request_body(client: BytesClient, png_data: bytes): client.request_body.default( - value=bytes("test", "utf-8"), + value=png_data, ) client.request_body.octet_stream( value=png_data, @@ -121,8 +121,9 @@ def test_request_body(client: BytesClient, png_data: bytes): def test_response_body(client: BytesClient, png_data: bytes): expected = b"test" - assert expected == client.response_body.default() + assert b"".join(client.response_body.default()) == png_data assert expected == client.response_body.base64() - assert expected == client.response_body.base64_url() assert b"".join(client.response_body.octet_stream()) == png_data assert b"".join(client.response_body.custom_content_type()) == png_data + # will reopen after TCGC release a fix version for https://github.com/Azure/typespec-azure/pull/2411 + # assert expected == client.response_body.base64_url() diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_parameters_collection_format.py b/packages/typespec-python/test/generic_mock_api_tests/test_parameters_collection_format.py index ab55144e855..283a7080f7f 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_parameters_collection_format.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_parameters_collection_format.py @@ -29,9 +29,5 @@ def test_query_ssv(client: CollectionFormatClient): client.query.ssv(colors=["blue", "red", "green"]) -def test_query_tsv(client: CollectionFormatClient): - client.query.tsv(colors=["blue", "red", "green"]) - - def test_csv_header(client: CollectionFormatClient): client.header.csv(colors=["blue", "red", "green"]) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py index b32a6625993..45445d9c425 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py @@ -236,6 +236,7 @@ def test_spread_model_array(client: AdditionalPropertiesClient): client.spread_model_array.put(body) +@pytest.mark.skip(reason="https://github.com/microsoft/typespec/pull/6425") def test_spread_record_discriminated_union(client: AdditionalPropertiesClient): body = { "name": "abc", From 30c8bc5e7834aa92d4b9bbf5c3e2b8c979d3425d Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Mar 2025 14:38:22 +0800 Subject: [PATCH 6/9] add changelog --- ...-microsoft-publish-python-release-2025-2-20-14-38-6.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md diff --git a/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md b/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md new file mode 100644 index 00000000000..82191ef4a5a --- /dev/null +++ b/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md @@ -0,0 +1,8 @@ +--- +changeKind: dependencies +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Bump `@typespec/*` 0.67 \ No newline at end of file From 08dcbde9c9ccb6c20cb720a2245a9ebd356ee99b Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 20 Mar 2025 07:24:09 +0000 Subject: [PATCH 7/9] Update dependencies (2025-03-20 07:24:09) --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 6 +- pnpm-lock.yaml | 149 +++++++++++--------------- 3 files changed, 66 insertions(+), 91 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index df03a548fa4..935ecca286d 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 8aca2ec667f..4f61ef69ecd 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { @@ -74,8 +74,8 @@ "@azure-tools/typespec-azure-rulesets": "~0.53.0", "@azure-tools/typespec-autorest": "~0.53.0", "@azure-tools/typespec-client-generator-core": "~0.53.0", - "@azure-tools/azure-http-specs": "0.1.0-alpha.9", - "@typespec/http-specs": "0.1.0-alpha.13", + "@azure-tools/azure-http-specs": "0.1.0-alpha.10", + "@typespec/http-specs": "0.1.0-alpha.15-dev.3", "@types/js-yaml": "~4.0.5", "@types/node": "~22.5.4", "@types/yargs": "~17.0.33", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fdbf03263ba..632651d4d03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -95,8 +95,8 @@ importers: version: 4.19.3 devDependencies: '@azure-tools/azure-http-specs': - specifier: 0.1.0-alpha.9 - version: 0.1.0-alpha.9(hxmxu44wsiwmqbpvyuomrsmujq) + specifier: 0.1.0-alpha.10 + version: 0.1.0-alpha.10(hxmxu44wsiwmqbpvyuomrsmujq) '@azure-tools/typespec-autorest': specifier: ~0.53.0 version: 0.53.0(vsru7ipd7qt42slknz5aanwsou) @@ -134,8 +134,8 @@ importers: specifier: ~0.67.0 version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) '@typespec/http-specs': - specifier: 0.1.0-alpha.13 - version: 0.1.0-alpha.13(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5))) + specifier: 0.1.0-alpha.15-dev.3 + version: 0.1.0-alpha.15-dev.3(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5))) '@typespec/openapi': specifier: ~0.67.0 version: 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))) @@ -179,16 +179,16 @@ packages: resolution: {integrity: sha512-T21naRb6JDdjjn2s/zwr9iCIv/9jviL/PRtiWAhi+3UA2WKH2wrId2VqJa4uVD7iEV8BLkuGgFmMkaMBG26hFw==} engines: {node: '>=12.0.0'} - '@azure-tools/azure-http-specs@0.1.0-alpha.9': - resolution: {integrity: sha512-eygzmoU/MnbhUB54C/fgRX3/98j3we6MYmrLhHSeLtLxVKG3upBxS7gHF0l7jnCE8+jMoaQ1o1WL7xLZuVEifg==} + '@azure-tools/azure-http-specs@0.1.0-alpha.10': + resolution: {integrity: sha512-BhWKqX6EMx16jMylLQG1m+Ncl5xoycqOTgxmaUkWNlFT0xT4AZqq1P5l15DgS77imJqHqI9VDOqt/vzN0LCJAQ==} engines: {node: '>=20.0.0'} peerDependencies: '@azure-tools/typespec-azure-core': ^0.53.0 - '@typespec/compiler': ^0.67.0 - '@typespec/http': ^0.67.0 - '@typespec/rest': ^0.67.0 - '@typespec/versioning': ^0.67.0 - '@typespec/xml': ^0.67.0 + '@typespec/compiler': ^0.67.1 + '@typespec/http': ^0.67.1 + '@typespec/rest': ^0.67.1 + '@typespec/versioning': ^0.67.1 + '@typespec/xml': ^0.67.1 '@azure-tools/typespec-autorest@0.53.0': resolution: {integrity: sha512-9eAOTU/so8QOigMcy9YKA43jtMxccSP22wa7Is0ZiX59YTcaUDGlpI+6cFfmGH0tATGCOm5TvjyOkdrhNyKrPw==} @@ -1535,8 +1535,8 @@ packages: peerDependencies: '@typespec/compiler': ^0.67.1 - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz} + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz} version: 0.8.1 engines: {node: '>=18.0.0'} peerDependencies: @@ -1551,15 +1551,15 @@ packages: '@typespec/rest': '>=0.67.0 <1.0.0' '@typespec/versioning': '>=0.67.0 <1.0.0' - '@typespec/http-specs@0.1.0-alpha.13': - resolution: {integrity: sha512-QBJNnXWCYShI5PSt89oCvSwFsXV/9kYBXSxWaPHYk0qa6CjUdMEbwZrSbV1BDhcyqbFE3e2LLCjX8dTjWJ6Fuw==} + '@typespec/http-specs@0.1.0-alpha.15-dev.3': + resolution: {integrity: sha512-pWrtceHjixwFv6SX1nkSu5WG7odm83FqnKLVzmO5Y29MD4DCgu1AhqtDM7UJ1GZgfHPbZS0zh9gj/01vxEhkdQ==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ^0.67.0 - '@typespec/http': ^0.67.0 - '@typespec/rest': ^0.67.0 - '@typespec/versioning': ^0.67.0 - '@typespec/xml': ^0.67.0 + '@typespec/compiler': ^0.67.1 || >=0.68.0-dev <0.68.0 + '@typespec/http': ^0.67.1 || >=0.68.0-dev <0.68.0 + '@typespec/rest': ^0.67.1 || >=0.68.0-dev <0.68.0 + '@typespec/versioning': ^0.67.1 || >=0.68.0-dev <0.68.0 + '@typespec/xml': ^0.67.1 || >=0.68.0-dev <0.68.0 '@typespec/http@0.67.1': resolution: {integrity: sha512-pkLFdKLA5ObCptUuwL8mhiy6EqVbqmtvHK89zqiTfYYGw2qm76+EUHaK0P/g2aAmjcwlrDGhJ0EhzbVp87H0mg==} @@ -2248,10 +2248,6 @@ packages: resolution: {integrity: sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==} engines: {node: '>= 0.4'} - es-define-property@1.0.0: - resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} - engines: {node: '>= 0.4'} - es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -2274,10 +2270,6 @@ packages: resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} engines: {node: '>= 0.4'} - es-set-tostringtag@2.0.3: - resolution: {integrity: sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==} - engines: {node: '>= 0.4'} - es-set-tostringtag@2.1.0: resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} engines: {node: '>= 0.4'} @@ -2682,9 +2674,6 @@ packages: resolution: {integrity: sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==} engines: {node: '>=18'} - gopd@1.0.1: - resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -4521,7 +4510,7 @@ snapshots: command-exists: 1.2.9 semver: 7.6.3 - '@azure-tools/azure-http-specs@0.1.0-alpha.9(hxmxu44wsiwmqbpvyuomrsmujq)': + '@azure-tools/azure-http-specs@0.1.0-alpha.10(hxmxu44wsiwmqbpvyuomrsmujq)': dependencies: '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) '@typespec/compiler': 0.67.1(@types/node@22.5.5) @@ -6155,7 +6144,7 @@ snapshots: dependencies: '@typespec/compiler': 0.67.1(@types/node@22.5.5) - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(nzqsibdudqbld3r7bpinzdupvm) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) @@ -6176,7 +6165,7 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY2Njg2My9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(vsru7ipd7qt42slknz5aanwsou) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))) @@ -6197,7 +6186,7 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-specs@0.1.0-alpha.13(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)))': + '@typespec/http-specs@0.1.0-alpha.15-dev.3(@types/node@22.5.5)(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/versioning@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))(@typespec/xml@0.59.0(@typespec/compiler@0.67.1(@types/node@22.5.5)))': dependencies: '@typespec/compiler': 0.67.1(@types/node@22.5.5) '@typespec/http': 0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))) @@ -6493,7 +6482,7 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.23.3 es-errors: 1.3.0 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 is-array-buffer: 3.0.4 is-shared-array-buffer: 1.0.3 @@ -6620,10 +6609,10 @@ snapshots: call-bind@1.0.7: dependencies: - es-define-property: 1.0.0 + es-define-property: 1.0.1 es-errors: 1.3.0 function-bind: 1.1.2 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 set-function-length: 1.2.2 callsites@3.1.0: {} @@ -6966,9 +6955,9 @@ snapshots: define-data-property@1.1.4: dependencies: - es-define-property: 1.0.0 + es-define-property: 1.0.1 es-errors: 1.3.0 - gopd: 1.0.1 + gopd: 1.2.0 define-lazy-prop@3.0.0: {} @@ -7055,19 +7044,19 @@ snapshots: data-view-buffer: 1.0.1 data-view-byte-length: 1.0.1 data-view-byte-offset: 1.0.0 - es-define-property: 1.0.0 + es-define-property: 1.0.1 es-errors: 1.3.0 - es-object-atoms: 1.0.0 - es-set-tostringtag: 2.0.3 + es-object-atoms: 1.1.1 + es-set-tostringtag: 2.1.0 es-to-primitive: 1.2.1 function.prototype.name: 1.1.6 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 get-symbol-description: 1.0.2 globalthis: 1.0.4 - gopd: 1.0.1 + gopd: 1.2.0 has-property-descriptors: 1.0.2 has-proto: 1.0.3 - has-symbols: 1.0.3 + has-symbols: 1.1.0 hasown: 2.0.2 internal-slot: 1.0.7 is-array-buffer: 3.0.4 @@ -7095,10 +7084,6 @@ snapshots: unbox-primitive: 1.0.2 which-typed-array: 1.1.15 - es-define-property@1.0.0: - dependencies: - get-intrinsic: 1.2.4 - es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -7106,8 +7091,8 @@ snapshots: es-get-iterator@1.1.3: dependencies: call-bind: 1.0.7 - get-intrinsic: 1.2.4 - has-symbols: 1.0.3 + get-intrinsic: 1.3.0 + has-symbols: 1.1.0 is-arguments: 1.1.1 is-map: 2.0.3 is-set: 2.0.3 @@ -7125,12 +7110,6 @@ snapshots: dependencies: es-errors: 1.3.0 - es-set-tostringtag@2.0.3: - dependencies: - get-intrinsic: 1.2.4 - has-tostringtag: 1.0.2 - hasown: 2.0.2 - es-set-tostringtag@2.1.0: dependencies: es-errors: 1.3.0 @@ -7623,7 +7602,7 @@ snapshots: es-errors: 1.3.0 function-bind: 1.1.2 has-proto: 1.0.3 - has-symbols: 1.0.3 + has-symbols: 1.1.0 hasown: 2.0.2 get-intrinsic@1.3.0: @@ -7650,7 +7629,7 @@ snapshots: dependencies: call-bind: 1.0.7 es-errors: 1.3.0 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 get-tsconfig@4.8.1: dependencies: @@ -7710,7 +7689,7 @@ snapshots: globalthis@1.0.4: dependencies: define-properties: 1.2.1 - gopd: 1.0.1 + gopd: 1.2.0 globby@14.0.2: dependencies: @@ -7730,10 +7709,6 @@ snapshots: slash: 5.1.0 unicorn-magic: 0.3.0 - gopd@1.0.1: - dependencies: - get-intrinsic: 1.2.4 - gopd@1.2.0: {} graceful-fs@4.2.11: {} @@ -7750,7 +7725,7 @@ snapshots: has-property-descriptors@1.0.2: dependencies: - es-define-property: 1.0.0 + es-define-property: 1.0.1 has-proto@1.0.3: {} @@ -7858,7 +7833,7 @@ snapshots: is-array-buffer@3.0.4: dependencies: call-bind: 1.0.7 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 is-arrayish@0.2.1: {} @@ -7944,7 +7919,7 @@ snapshots: is-symbol@1.0.4: dependencies: - has-symbols: 1.0.3 + has-symbols: 1.1.0 is-typed-array@1.1.13: dependencies: @@ -7965,7 +7940,7 @@ snapshots: is-weakset@2.0.3: dependencies: call-bind: 1.0.7 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 is-wsl@3.1.0: dependencies: @@ -8421,7 +8396,7 @@ snapshots: dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - has-symbols: 1.0.3 + has-symbols: 1.1.0 object-keys: 1.1.1 object.fromentries@2.0.8: @@ -8803,8 +8778,8 @@ snapshots: safe-array-concat@1.1.2: dependencies: call-bind: 1.0.7 - get-intrinsic: 1.2.4 - has-symbols: 1.0.3 + get-intrinsic: 1.3.0 + has-symbols: 1.1.0 isarray: 2.0.5 safe-buffer@5.1.2: {} @@ -8863,8 +8838,8 @@ snapshots: define-data-property: 1.1.4 es-errors: 1.3.0 function-bind: 1.1.2 - get-intrinsic: 1.2.4 - gopd: 1.0.1 + get-intrinsic: 1.3.0 + gopd: 1.2.0 has-property-descriptors: 1.0.2 set-function-name@2.0.2: @@ -8886,7 +8861,7 @@ snapshots: dependencies: call-bind: 1.0.7 es-errors: 1.3.0 - get-intrinsic: 1.2.4 + get-intrinsic: 1.3.0 object-inspect: 1.13.2 siginfo@2.0.0: {} @@ -9003,19 +8978,19 @@ snapshots: call-bind: 1.0.7 define-properties: 1.2.1 es-abstract: 1.23.3 - es-object-atoms: 1.0.0 + es-object-atoms: 1.1.1 string.prototype.trimend@1.0.8: dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-object-atoms: 1.0.0 + es-object-atoms: 1.1.1 string.prototype.trimstart@1.0.8: dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-object-atoms: 1.0.0 + es-object-atoms: 1.1.1 string_decoder@1.1.1: dependencies: @@ -9201,7 +9176,7 @@ snapshots: dependencies: call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 + gopd: 1.2.0 has-proto: 1.0.3 is-typed-array: 1.1.13 @@ -9210,7 +9185,7 @@ snapshots: available-typed-arrays: 1.0.7 call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 + gopd: 1.2.0 has-proto: 1.0.3 is-typed-array: 1.1.13 @@ -9218,7 +9193,7 @@ snapshots: dependencies: call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 + gopd: 1.2.0 has-proto: 1.0.3 is-typed-array: 1.1.13 possible-typed-array-names: 1.0.0 @@ -9260,7 +9235,7 @@ snapshots: dependencies: call-bind: 1.0.7 has-bigints: 1.0.2 - has-symbols: 1.0.3 + has-symbols: 1.1.0 which-boxed-primitive: 1.0.2 underscore@1.13.7: {} @@ -9438,7 +9413,7 @@ snapshots: available-typed-arrays: 1.0.7 call-bind: 1.0.7 for-each: 0.3.3 - gopd: 1.0.1 + gopd: 1.2.0 has-tostringtag: 1.0.2 which@2.0.2: From 7915f8368a38f0e5d774042e10372cb47e45c1ec Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 20 Mar 2025 07:28:19 +0000 Subject: [PATCH 8/9] Regenerate for typespec-python (2025-03-20 07:28:19) --- .../core/basic/_operations/_operations.py | 32 ++-- .../core/basic/aio/_operations/_operations.py | 4 +- .../lro/standard/_operations/_operations.py | 15 +- .../standard/aio/_operations/_operations.py | 2 +- .../core/page/aio/operations/_operations.py | 2 +- .../azure/core/page/operations/_operations.py | 30 ++-- .../core/scalar/aio/operations/_operations.py | 13 +- .../core/scalar/operations/_operations.py | 21 +-- .../core/traits/_operations/_operations.py | 9 +- .../traits/aio/_operations/_operations.py | 2 +- .../example/basic/_operations/_operations.py | 7 +- .../basic/aio/_operations/_operations.py | 2 +- .../aio/operations/_operations.py | 6 +- .../operations/_operations.py | 46 ++---- .../aio/operations/_operations.py | 8 +- .../operations/_operations.py | 41 ++--- .../resources/aio/operations/_operations.py | 22 +-- .../resources/operations/_operations.py | 152 +++++++----------- .../lro/rpc/_operations/_operations.py | 5 +- .../lro/rpc/aio/_operations/_operations.py | 2 +- .../naming/aio/operations/_operations.py | 8 +- .../client/naming/operations/_operations.py | 12 +- .../bytes/aio/operations/_operations.py | 48 +++--- .../encode/bytes/operations/_operations.py | 56 ++++--- .../resiliency/srv/driven1/_client.py | 11 +- .../resiliency/srv/driven1/_configuration.py | 11 +- .../resiliency/srv/driven1/aio/_client.py | 11 +- .../srv/driven1/aio/_configuration.py | 11 +- .../resiliency/srv/driven2/_client.py | 11 +- .../resiliency/srv/driven2/_configuration.py | 11 +- .../resiliency/srv/driven2/aio/_client.py | 11 +- .../srv/driven2/aio/_configuration.py | 11 +- .../_operations/_operations.py | 64 +++----- .../aio/_operations/_operations.py | 58 ++----- .../server/path/multiple/_client.py | 12 +- .../server/path/multiple/_configuration.py | 12 +- .../server/path/multiple/aio/_client.py | 12 +- .../path/multiple/aio/_configuration.py | 12 +- .../versioned/_operations/_operations.py | 15 +- .../extensible/aio/operations/_operations.py | 25 +-- .../enum/extensible/operations/_operations.py | 33 ++-- .../enum/fixed/aio/operations/_operations.py | 9 +- .../enum/fixed/operations/_operations.py | 13 +- .../scalar/aio/operations/_operations.py | 59 ++++--- .../typetest/scalar/operations/_operations.py | 81 ++++++---- .../_operations/_operations.py | 9 +- .../aio/_operations/_operations.py | 7 +- .../requestbody/aio/operations/_operations.py | 10 +- .../requestbody/operations/_operations.py | 14 +- .../aio/operations/_operations.py | 41 +++-- .../responsebody/operations/_operations.py | 45 ++++-- .../_operations/_operations.py | 64 +++----- .../aio/_operations/_operations.py | 58 ++----- .../server/path/multiple/_client.py | 12 +- .../server/path/multiple/_configuration.py | 12 +- .../server/path/multiple/aio/_client.py | 12 +- .../path/multiple/aio/_configuration.py | 12 +- .../versioned/_operations/_operations.py | 15 +- .../extensible/aio/operations/_operations.py | 25 +-- .../enum/extensible/operations/_operations.py | 33 ++-- .../enum/fixed/aio/operations/_operations.py | 9 +- .../enum/fixed/operations/_operations.py | 13 +- .../scalar/aio/operations/_operations.py | 59 ++++--- .../typetest/scalar/operations/_operations.py | 81 ++++++---- .../_operations/_operations.py | 9 +- .../aio/_operations/_operations.py | 7 +- 66 files changed, 800 insertions(+), 785 deletions(-) diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py index f63c4cb6379..28fd837cb2d 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_operations/_operations.py @@ -44,13 +44,12 @@ _SERIALIZER.client_side_validation = False -def build_basic_create_or_update_request( - id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_basic_create_or_update_request(id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,13 +71,12 @@ def build_basic_create_or_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_create_or_replace_request( - id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_basic_create_or_replace_request(id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,10 +98,11 @@ def build_basic_create_or_replace_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_get_request(id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_basic_get_request(id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,12 +131,12 @@ def build_basic_list_request( filter: Optional[str] = None, select: Optional[List[str]] = None, expand: Optional[List[str]] = None, - api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,10 +165,11 @@ def build_basic_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_delete_request(id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_basic_delete_request(id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,12 +189,11 @@ def build_basic_delete_request(id: int, *, api_version: str = "2022-12-01-previe return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_export_request( - id: int, *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_basic_export_request(id: int, *, format: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,12 +214,11 @@ def build_basic_export_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_basic_export_all_users_request( - *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_basic_export_all_users_request(*, format: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -336,8 +334,8 @@ def create_or_update(self, id: int, resource: Union[_models.User, JSON, IO[bytes _request = build_basic_create_or_update_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -471,8 +469,8 @@ def create_or_replace(self, id: int, resource: Union[_models.User, JSON, IO[byte _request = build_basic_create_or_replace_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py index 423a76142b0..8142baeff57 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py @@ -153,8 +153,8 @@ async def create_or_update( _request = build_basic_create_or_update_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -290,8 +290,8 @@ async def create_or_replace( _request = build_basic_create_or_replace_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py index 5fae701c611..46281ebcfa9 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_operations/_operations.py @@ -44,13 +44,12 @@ _SERIALIZER.client_side_validation = False -def build_standard_create_or_replace_request( - name: str, *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_standard_create_or_replace_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,10 +71,11 @@ def build_standard_create_or_replace_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_standard_delete_request(name: str, *, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_standard_delete_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,12 +95,11 @@ def build_standard_delete_request(name: str, *, api_version: str = "2022-12-01-p return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_standard_export_request( - name: str, *, format: str, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_standard_export_request(name: str, *, format: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,8 +148,8 @@ def _create_or_replace_initial( _request = build_standard_create_or_replace_request( name=name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py index 6aeb27d4078..d4b2420ffa8 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py @@ -74,8 +74,8 @@ async def _create_or_replace_initial( _request = build_standard_create_or_replace_request( name=name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py index 857c4081c22..8e6733fd50a 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py @@ -434,8 +434,8 @@ def prepare_request(next_link=None): _request = build_page_list_with_parameters_request( another=another, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py index e5dfe73c258..c31207bd525 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/operations/_operations.py @@ -45,11 +45,12 @@ def build_two_models_as_page_item_list_first_item_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,11 +66,12 @@ def build_two_models_as_page_item_list_first_item_request( # pylint: disable=na def build_two_models_as_page_item_list_second_item_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,10 +86,11 @@ def build_two_models_as_page_item_list_second_item_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_page_list_with_page_request(*, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_page_list_with_page_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,15 +106,13 @@ def build_page_list_with_page_request(*, api_version: str = "2022-12-01-preview" def build_page_list_with_parameters_request( - *, - another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, - api_version: str = "2022-12-01-preview", - **kwargs: Any + *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,12 +131,11 @@ def build_page_list_with_parameters_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_page_list_with_custom_page_model_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_page_list_with_custom_page_model_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +425,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any + **kwargs: Any, ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -449,7 +449,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any + **kwargs: Any, ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -473,7 +473,7 @@ def list_with_parameters( *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, content_type: str = "application/json", - **kwargs: Any + **kwargs: Any, ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -496,7 +496,7 @@ def list_with_parameters( body_input: Union[_models.ListItemInputBody, JSON, IO[bytes]], *, another: Optional[Union[str, _models.ListItemInputExtensibleEnum]] = None, - **kwargs: Any + **kwargs: Any, ) -> Iterable["_models.User"]: """List with extensible enum parameter Azure.Core.Page<>. @@ -535,8 +535,8 @@ def prepare_request(next_link=None): _request = build_page_list_with_parameters_request( another=another, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py index d24b2bddf28..6ba2ffd71ce 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/aio/operations/_operations.py @@ -110,13 +110,16 @@ async def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -141,10 +144,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_azure_location_scalar_put_request( content_type=content_type, @@ -242,7 +245,7 @@ async def post( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) cls: ClsType[_models.AzureLocationModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py index a5136bcb1f6..17aa7fce608 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/operations/_operations.py @@ -46,7 +46,7 @@ def build_azure_location_scalar_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/azure/core/scalar/azureLocation" @@ -65,7 +65,7 @@ def build_azure_location_scalar_put_request(**kwargs: Any) -> HttpRequest: _url = "/azure/core/scalar/azureLocation" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -73,7 +73,7 @@ def build_azure_location_scalar_put_request(**kwargs: Any) -> HttpRequest: def build_azure_location_scalar_post_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +81,7 @@ def build_azure_location_scalar_post_request(**kwargs: Any) -> HttpRequest: # Construct headers if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -178,13 +178,16 @@ def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -209,10 +212,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_azure_location_scalar_put_request( content_type=content_type, @@ -308,7 +311,7 @@ def post( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) cls: ClsType[_models.AzureLocationModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py index 5b3a1b965c8..bbb6ea903a3 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_operations/_operations.py @@ -54,12 +54,12 @@ def build_traits_smoke_test_request( if_modified_since: Optional[datetime.datetime] = None, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, - api_version: str = "2022-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,13 +90,12 @@ def build_traits_smoke_test_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_traits_repeatable_action_request( - id: int, *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_traits_repeatable_action_request(id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -319,8 +318,8 @@ def repeatable_action( _request = build_traits_repeatable_action_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py index d36b4abdbf8..0cdec372bb8 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py @@ -238,8 +238,8 @@ async def repeatable_action( _request = build_traits_repeatable_action_request( id=id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py index 17908c42403..0e8f98efa24 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_operations/_operations.py @@ -42,13 +42,12 @@ _SERIALIZER.client_side_validation = False -def build_azure_example_basic_action_request( - *, query_param: str, header_param: str, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_azure_example_basic_action_request(*, query_param: str, header_param: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,8 +180,8 @@ def basic_action( _request = build_azure_example_basic_action_request( query_param=query_param, header_param=header_param, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py index 0114696dc45..475464cd1bb 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py @@ -154,8 +154,8 @@ async def basic_action( _request = build_azure_example_basic_action_request( query_param=query_param, header_param=header_param, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py index 61761fa1dfc..0784ca748f6 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/aio/operations/_operations.py @@ -267,8 +267,8 @@ async def create_with_system_assigned( resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -438,8 +438,8 @@ async def update_with_user_assigned_and_system_assigned( # pylint: disable=name resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -691,8 +691,8 @@ async def create_for_user_defined_error( resource_group_name=resource_group_name, confidential_resource_name=confidential_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py index c9e7e48dd0c..2e32ebb6d62 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py @@ -46,16 +46,12 @@ def build_managed_identity_get_request( - resource_group_name: str, - managed_identity_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,17 +76,13 @@ def build_managed_identity_get_request( def build_managed_identity_create_with_system_assigned_request( # pylint: disable=name-too-long - resource_group_name: str, - managed_identity_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,17 +109,13 @@ def build_managed_identity_create_with_system_assigned_request( # pylint: disab def build_managed_identity_update_with_user_assigned_and_system_assigned_request( # pylint: disable=name-too-long - resource_group_name: str, - managed_identity_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, managed_identity_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,16 +142,12 @@ def build_managed_identity_update_with_user_assigned_and_system_assigned_request def build_error_get_for_predefined_error_request( # pylint: disable=name-too-long - resource_group_name: str, - confidential_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,17 +170,13 @@ def build_error_get_for_predefined_error_request( # pylint: disable=name-too-lo def build_error_create_for_user_defined_error_request( # pylint: disable=name-too-long - resource_group_name: str, - confidential_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, confidential_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -439,8 +419,8 @@ def create_with_system_assigned( resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -610,8 +590,8 @@ def update_with_user_assigned_and_system_assigned( # pylint: disable=name-too-l resource_group_name=resource_group_name, managed_identity_tracked_resource_name=managed_identity_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -863,8 +843,8 @@ def create_for_user_defined_error( resource_group_name=resource_group_name, confidential_resource_name=confidential_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py index 057d8550cf9..d93d71dc040 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py @@ -263,8 +263,8 @@ async def check_global( _request = build_check_name_availability_check_global_request( subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -404,8 +404,8 @@ async def check_local( _request = build_check_name_availability_check_local_request( location=location, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -488,8 +488,8 @@ async def _create_or_replace_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -720,8 +720,8 @@ async def _export_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py index e5f533d37f8..124f552c529 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py @@ -49,10 +49,11 @@ _SERIALIZER.client_side_validation = False -def build_operations_list_request(*, api_version: str = "2023-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,12 +69,13 @@ def build_operations_list_request(*, api_version: str = "2023-12-01-preview", ** def build_check_name_availability_check_global_request( # pylint: disable=name-too-long - subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,12 +98,13 @@ def build_check_name_availability_check_global_request( # pylint: disable=name- def build_check_name_availability_check_local_request( # pylint: disable=name-too-long - location: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,17 +128,13 @@ def build_check_name_availability_check_local_request( # pylint: disable=name-t def build_lro_create_or_replace_request( - resource_group_name: str, - order_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,17 +159,13 @@ def build_lro_create_or_replace_request( def build_lro_export_request( - resource_group_name: str, - order_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,16 +190,12 @@ def build_lro_export_request( def build_lro_delete_request( - resource_group_name: str, - order_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, order_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -434,8 +425,8 @@ def check_global( _request = build_check_name_availability_check_global_request( subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -575,8 +566,8 @@ def check_local( _request = build_check_name_availability_check_local_request( location=location, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -659,8 +650,8 @@ def _create_or_replace_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -887,8 +878,8 @@ def _export_initial( resource_group_name=resource_group_name, order_name=order_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py index a8a585b1d1a..23941e40e61 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/aio/operations/_operations.py @@ -192,8 +192,8 @@ async def _create_or_replace_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -429,8 +429,8 @@ async def _update_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1052,8 +1052,8 @@ async def action_sync( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1205,8 +1205,8 @@ async def _create_or_replace_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1457,8 +1457,8 @@ async def _update_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2007,8 +2007,8 @@ async def _create_or_update_initial( _request = build_singleton_create_or_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2299,8 +2299,8 @@ async def update( _request = build_singleton_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2542,8 +2542,8 @@ async def _create_or_update_initial( _request = build_extensions_resources_create_or_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2874,8 +2874,8 @@ async def update( _request = build_extensions_resources_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -3260,8 +3260,8 @@ async def create_or_update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -3422,8 +3422,8 @@ async def update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py index 0c9054ad499..5932659b7c6 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py @@ -50,16 +50,12 @@ def build_top_level_get_request( - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,17 +80,13 @@ def build_top_level_get_request( def build_top_level_create_or_replace_request( # pylint: disable=name-too-long - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,17 +113,13 @@ def build_top_level_create_or_replace_request( # pylint: disable=name-too-long def build_top_level_update_request( - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,16 +146,12 @@ def build_top_level_update_request( def build_top_level_delete_request( - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,11 +176,12 @@ def build_top_level_delete_request( def build_top_level_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -218,11 +203,12 @@ def build_top_level_list_by_resource_group_request( # pylint: disable=name-too- def build_top_level_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,17 +229,13 @@ def build_top_level_list_by_subscription_request( # pylint: disable=name-too-lo def build_top_level_action_sync_request( - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -284,13 +266,12 @@ def build_nested_get_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, - *, - api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -320,14 +301,13 @@ def build_nested_create_or_replace_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, - *, - api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -359,14 +339,13 @@ def build_nested_update_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, - *, - api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -398,13 +377,12 @@ def build_nested_delete_request( top_level_tracked_resource_name: str, nexted_proxy_resource_name: str, subscription_id: str, - *, - api_version: str = "2023-12-01-preview", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -430,16 +408,12 @@ def build_nested_delete_request( def build_nested_list_by_top_level_tracked_resource_request( # pylint: disable=name-too-long - resource_group_name: str, - top_level_tracked_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + resource_group_name: str, top_level_tracked_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -464,11 +438,12 @@ def build_nested_list_by_top_level_tracked_resource_request( # pylint: disable= def build_singleton_get_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -490,12 +465,13 @@ def build_singleton_get_by_resource_group_request( # pylint: disable=name-too-l def build_singleton_create_or_update_request( - resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -518,13 +494,12 @@ def build_singleton_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_singleton_update_request( - resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_singleton_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -548,11 +523,12 @@ def build_singleton_update_request( def build_singleton_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -574,11 +550,12 @@ def build_singleton_list_by_resource_group_request( # pylint: disable=name-too- def build_extensions_resources_get_request( - resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_uri: str, extensions_resource_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -600,12 +577,13 @@ def build_extensions_resources_get_request( def build_extensions_resources_create_or_update_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_uri: str, extensions_resource_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -629,12 +607,13 @@ def build_extensions_resources_create_or_update_request( # pylint: disable=name def build_extensions_resources_update_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_uri: str, extensions_resource_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -658,11 +637,12 @@ def build_extensions_resources_update_request( # pylint: disable=name-too-long def build_extensions_resources_delete_request( # pylint: disable=name-too-long - resource_uri: str, extensions_resource_name: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_uri: str, extensions_resource_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -684,11 +664,12 @@ def build_extensions_resources_delete_request( # pylint: disable=name-too-long def build_extensions_resources_list_by_scope_request( # pylint: disable=name-too-long - resource_uri: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + resource_uri: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -709,16 +690,12 @@ def build_extensions_resources_list_by_scope_request( # pylint: disable=name-to def build_location_resources_get_request( - location: str, - location_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + location: str, location_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -741,17 +718,13 @@ def build_location_resources_get_request( def build_location_resources_create_or_update_request( # pylint: disable=name-too-long - location: str, - location_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + location: str, location_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -776,17 +749,13 @@ def build_location_resources_create_or_update_request( # pylint: disable=name-t def build_location_resources_update_request( - location: str, - location_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + location: str, location_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -811,16 +780,12 @@ def build_location_resources_update_request( def build_location_resources_delete_request( - location: str, - location_resource_name: str, - subscription_id: str, - *, - api_version: str = "2023-12-01-preview", - **kwargs: Any + location: str, location_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -843,11 +808,12 @@ def build_location_resources_delete_request( def build_location_resources_list_by_location_request( # pylint: disable=name-too-long - location: str, subscription_id: str, *, api_version: str = "2023-12-01-preview", **kwargs: Any + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -985,8 +951,8 @@ def _create_or_replace_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1222,8 +1188,8 @@ def _update_initial( resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1845,8 +1811,8 @@ def action_sync( # pylint: disable=inconsistent-return-statements resource_group_name=resource_group_name, top_level_tracked_resource_name=top_level_tracked_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -1998,8 +1964,8 @@ def _create_or_replace_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2250,8 +2216,8 @@ def _update_initial( top_level_tracked_resource_name=top_level_tracked_resource_name, nexted_proxy_resource_name=nexted_proxy_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -2800,8 +2766,8 @@ def _create_or_update_initial( _request = build_singleton_create_or_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -3092,8 +3058,8 @@ def update( _request = build_singleton_update_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -3335,8 +3301,8 @@ def _create_or_update_initial( _request = build_extensions_resources_create_or_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -3667,8 +3633,8 @@ def update( _request = build_extensions_resources_update_request( resource_uri=resource_uri, extensions_resource_name=extensions_resource_name, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -4055,8 +4021,8 @@ def create_or_update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, @@ -4217,8 +4183,8 @@ def update( location=location, location_resource_name=location_resource_name, subscription_id=self._config.subscription_id, - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py index b8f0c7007ce..3e3fd504125 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_operations/_operations.py @@ -44,11 +44,12 @@ _SERIALIZER.client_side_validation = False -def build_rpc_long_running_rpc_request(*, api_version: str = "2022-12-01-preview", **kwargs: Any) -> HttpRequest: +def build_rpc_long_running_rpc_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,8 +93,8 @@ def _long_running_rpc_initial( _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_rpc_long_running_rpc_request( - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py index 7d34bf7cc24..0dfcbc34b98 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py @@ -69,8 +69,8 @@ async def _long_running_rpc_initial( _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_rpc_long_running_rpc_request( - api_version=self._config.api_version, content_type=content_type, + api_version=self._config.api_version, content=_content, headers=_headers, params=_params, diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py index e98f1e9273e..b5090696a04 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py @@ -307,10 +307,10 @@ async def union_enum_name(self, body: Union[str, _models.ClientExtensibleEnum], _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_union_enum_union_enum_name_request( content_type=content_type, @@ -358,10 +358,10 @@ async def union_enum_member_name(self, body: Union[str, _models.ExtensibleEnum], _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_union_enum_union_enum_member_name_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py index b233f965334..d880e3e6dc5 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py @@ -79,7 +79,7 @@ def build_union_enum_union_enum_name_request(**kwargs: Any) -> HttpRequest: _url = "/client/naming/union-enum/union-enum-name" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -92,7 +92,7 @@ def build_union_enum_union_enum_member_name_request(**kwargs: Any) -> HttpReques _url = "/client/naming/union-enum/union-enum-member-name" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -435,10 +435,10 @@ def union_enum_name( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_union_enum_union_enum_name_request( content_type=content_type, @@ -488,10 +488,10 @@ def union_enum_member_name( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_union_enum_union_enum_member_name_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py index 3776e4e7ec6..e84915c1d29 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/aio/operations/_operations.py @@ -1163,10 +1163,10 @@ async def base64(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore _request = build_request_body_base64_request( content_type=content_type, @@ -1214,10 +1214,10 @@ async def base64_url(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore _request = build_request_body_base64_url_request( content_type=content_type, @@ -1428,11 +1428,11 @@ async def custom_content_type(self, **kwargs: Any) -> AsyncIterator[bytes]: return deserialized # type: ignore @distributed_trace_async - async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: + async def base64(self, **kwargs: Any) -> bytes: """base64. - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: bytes + :rtype: bytes :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1446,7 +1446,7 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -1457,7 +1457,7 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1473,19 +1473,25 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: + async def base64_url(self, **kwargs: Any) -> bytes: """base64_url. - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: bytes + :rtype: bytes :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1499,7 +1505,7 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -1510,7 +1516,7 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1526,9 +1532,15 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py index 24635c43d46..51afaca22b0 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/operations/_operations.py @@ -255,7 +255,7 @@ def build_request_body_base64_request(**kwargs: Any) -> HttpRequest: _url = "/encode/bytes/body/request/base64" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -268,7 +268,7 @@ def build_request_body_base64_url_request(**kwargs: Any) -> HttpRequest: _url = "/encode/bytes/body/request/base64url" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -318,7 +318,7 @@ def build_response_body_custom_content_type_request(**kwargs: Any) -> HttpReques def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/octet-stream") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/encode/bytes/body/response/base64" @@ -332,7 +332,7 @@ def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: def build_response_body_base64_url_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/encode/bytes/body/response/base64url" @@ -1447,10 +1447,10 @@ def base64(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incons _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore _request = build_request_body_base64_request( content_type=content_type, @@ -1498,10 +1498,10 @@ def base64_url(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=in _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore _request = build_request_body_base64_url_request( content_type=content_type, @@ -1712,11 +1712,11 @@ def custom_content_type(self, **kwargs: Any) -> Iterator[bytes]: return deserialized # type: ignore @distributed_trace - def base64(self, **kwargs: Any) -> Iterator[bytes]: + def base64(self, **kwargs: Any) -> bytes: """base64. - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: bytes + :rtype: bytes :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1730,7 +1730,7 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -1741,7 +1741,7 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1757,19 +1757,25 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def base64_url(self, **kwargs: Any) -> Iterator[bytes]: + def base64_url(self, **kwargs: Any) -> bytes: """base64_url. - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: bytes + :rtype: bytes :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1783,7 +1789,7 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -1794,7 +1800,7 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1810,9 +1816,15 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py index 906d7f0c1e5..756ec034b3a 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py @@ -19,9 +19,7 @@ from ._serialization import Deserializer, Serializer -class ResiliencyServiceDrivenClient( - ResiliencyServiceDrivenClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword +class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -33,18 +31,19 @@ class ResiliencyServiceDrivenClient( version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Default value is "v1". + up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default + value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, *, api_version: str = "v1", **kwargs: Any + self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py index 0f7bdfbad4b..e4da6df9461 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_configuration.py @@ -26,12 +26,15 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :param api_version: Pass in 'v1'. This represents the API version of the service. Will grow up - in the next deployment to be both 'v1' and 'v2'. Default value is "v1". - :type api_version: str + :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow + up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default + value is "v1". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v1", **kwargs: Any) -> None: + def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py index fe3de4f6be1..6a04bc9462d 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py @@ -19,9 +19,7 @@ from ._operations import ResiliencyServiceDrivenClientOperationsMixin -class ResiliencyServiceDrivenClient( - ResiliencyServiceDrivenClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword +class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -33,18 +31,19 @@ class ResiliencyServiceDrivenClient( version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow - up in the next deployment to be both 'v1' and 'v2'. Default value is "v1". + up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default + value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, *, api_version: str = "v1", **kwargs: Any + self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py index 407ce9f4e79..8fc2b09c37f 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_configuration.py @@ -26,12 +26,15 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :param api_version: Pass in 'v1'. This represents the API version of the service. Will grow up - in the next deployment to be both 'v1' and 'v2'. Default value is "v1". - :type api_version: str + :keyword api_version: Pass in 'v1'. This represents the API version of the service. Will grow + up in the next deployment to be both 'v1' and 'v2'. Known values are "v1" and None. Default + value is "v1". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v1", **kwargs: Any) -> None: + def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py index cec65486da4..36d65156285 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py @@ -19,9 +19,7 @@ from ._serialization import Deserializer, Serializer -class ResiliencyServiceDrivenClient( - ResiliencyServiceDrivenClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword +class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -50,18 +48,19 @@ class ResiliencyServiceDrivenClient( version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Default value is "v2". + service. Known values are "v2" and None. Default value is "v2". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, *, api_version: str = "v2", **kwargs: Any + self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py index f561d533821..5a153640f3a 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_configuration.py @@ -26,12 +26,15 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :param api_version: Pass in either 'v1' or 'v2'. This represents the API version of a service. - Default value is "v2". - :type api_version: str + :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a + service. Known values are "v2" and None. Default value is "v2". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v2", **kwargs: Any) -> None: + def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v2") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py index e9d8d36b681..d782b2d8fd6 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py @@ -19,9 +19,7 @@ from ._operations import ResiliencyServiceDrivenClientOperationsMixin -class ResiliencyServiceDrivenClient( - ResiliencyServiceDrivenClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword +class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin): """Test that we can grow up a service spec and service deployment into a multi-versioned service with full client support. @@ -50,18 +48,19 @@ class ResiliencyServiceDrivenClient( version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a - service. Default value is "v2". + service. Known values are "v2" and None. Default value is "v2". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, service_deployment_version: str, *, api_version: str = "v2", **kwargs: Any + self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: _endpoint = ( "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" ) self._config = ResiliencyServiceDrivenClientConfiguration( - endpoint=endpoint, service_deployment_version=service_deployment_version, api_version=api_version, **kwargs + endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) _policies = kwargs.pop("policies", None) if _policies is None: diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py index d83aff6b69b..bd35e1c0c81 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_configuration.py @@ -26,12 +26,15 @@ class ResiliencyServiceDrivenClientConfiguration: # pylint: disable=too-many-in the service deployment in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when the service had api-versions 'v1' and 'v2'. Required. :type service_deployment_version: str - :param api_version: Pass in either 'v1' or 'v2'. This represents the API version of a service. - Default value is "v2". - :type api_version: str + :keyword api_version: Pass in either 'v1' or 'v2'. This represents the API version of a + service. Known values are "v2" and None. Default value is "v2". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__(self, endpoint: str, service_deployment_version: str, api_version: str = "v2", **kwargs: Any) -> None: + def __init__(self, endpoint: str, service_deployment_version: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v2") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if service_deployment_version is None: diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index 1e8b5c1dbce..051fecb957f 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Literal, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,8 +14,6 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -24,7 +22,7 @@ from azure.core.utils import case_insensitive_dict from .. import models as _models -from .._model_base import _deserialize, _failsafe_deserialize +from .._model_base import _failsafe_deserialize from .._serialization import Serializer from .._vendor import StatusCodeRangeClientMixinABC @@ -44,7 +42,7 @@ def build_status_code_range_error_response_status_code_in_range_request( # pyli ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/response/status-code-range/error-response-status-code-in-range" @@ -60,7 +58,7 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/response/status-code-range/error-response-status-code-404" @@ -74,11 +72,13 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): @distributed_trace - def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + def error_response_status_code_in_range( # pylint: disable=inconsistent-return-statements + self, **kwargs: Any + ) -> None: """error_response_status_code_in_range. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -92,7 +92,7 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code_in_range_request( headers=_headers, @@ -103,19 +103,14 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if 494 <= response.status_code <= 499: @@ -124,22 +119,15 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.DefaultError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + def error_response_status_code404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """error_response_status_code404. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -150,7 +138,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code404_request( headers=_headers, @@ -161,19 +149,14 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if response.status_code == 404: @@ -183,12 +166,5 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index 7029ac14e54..a3ab6eb372e 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Literal, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,8 +15,6 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -24,7 +22,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models -from ..._model_base import _deserialize, _failsafe_deserialize +from ..._model_base import _failsafe_deserialize from ..._operations._operations import ( build_status_code_range_error_response_status_code404_request, build_status_code_range_error_response_status_code_in_range_request, @@ -42,11 +40,11 @@ class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): @distributed_trace_async - async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + async def error_response_status_code_in_range(self, **kwargs: Any) -> None: """error_response_status_code_in_range. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -60,7 +58,7 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code_in_range_request( headers=_headers, @@ -71,19 +69,14 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if 494 <= response.status_code <= 499: @@ -92,22 +85,15 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 error = _failsafe_deserialize(_models.DefaultError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + async def error_response_status_code404(self, **kwargs: Any) -> None: """error_response_status_code404. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -118,7 +104,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code404_request( headers=_headers, @@ -129,19 +115,14 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if response.status_code == 404: @@ -151,12 +132,5 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py index 7f879513435..6925911ad4a 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_client.py @@ -7,34 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Union +from typing import Any from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse -from . import models as _models from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin from ._serialization import Deserializer, Serializer -class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class MultipleClient(MultipleClientOperationsMixin): """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any + self, endpoint: str, **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py index 9e17c72d27e..1a84717b685 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_configuration.py @@ -6,11 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Union +from typing import Any from azure.core.pipeline import policies -from . import models as _models from ._version import VERSION @@ -23,11 +22,14 @@ class MultipleClientConfiguration: # pylint: disable=too-many-instance-attribut :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". - :type api_version: str or ~server.path.multiple.models.Versions + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: + def __init__(self, endpoint: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1.0") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py index f9f091b603c..ebe8b6290b9 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_client.py @@ -7,34 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Union +from typing import Any, Awaitable from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest -from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin -class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class MultipleClient(MultipleClientOperationsMixin): """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any + self, endpoint: str, **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py index 663d0aa363e..ae9ecd544b7 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_configuration.py @@ -6,11 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Union +from typing import Any from azure.core.pipeline import policies -from .. import models as _models from .._version import VERSION @@ -23,11 +22,14 @@ class MultipleClientConfiguration: # pylint: disable=too-many-instance-attribut :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". - :type api_version: str or ~server.path.multiple.models.Versions + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: + def __init__(self, endpoint: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1.0") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py index 87d1db4878e..5cf481a18b1 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py @@ -42,11 +42,10 @@ def build_versioned_without_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_api_version_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-api-version" @@ -56,9 +55,8 @@ def build_versioned_with_query_api_version_request( # pylint: disable=name-too- return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_versioned_with_path_api_version_request( # pylint: disable=name-too-long - api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + api_version: str = kwargs.pop("api_version", "2022-12-01-preview") # Construct URL _url = "/server/versions/versioned/with-path-api-version/{apiVersion}" path_format_arguments = { @@ -70,11 +68,10 @@ def build_versioned_with_path_api_version_request( # pylint: disable=name-too-l return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_old_api_version_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_query_old_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-old-api-version" diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py index 8aa1318e410..16cef96f8f1 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -25,7 +26,7 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import _deserialize +from ..._model_base import SdkJSONEncoder, _deserialize from ..._serialization import Deserializer, Serializer from ...operations._operations import ( build_string_get_known_value_request, @@ -106,13 +107,16 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -162,13 +166,16 @@ async def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWee map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -194,10 +201,10 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekExtensibleEnu _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_known_value_request( content_type=content_type, @@ -246,10 +253,10 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekExtensibleE _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py index acdfc6e4e60..1596762f2dc 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -26,7 +27,7 @@ from .. import models as _models from .._configuration import ExtensibleClientConfiguration -from .._model_base import _deserialize +from .._model_base import SdkJSONEncoder, _deserialize from .._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -43,7 +44,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/enum/extensible/string/known-value" @@ -57,7 +58,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: def build_string_get_unknown_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/enum/extensible/string/unknown-value" @@ -76,7 +77,7 @@ def build_string_put_known_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/extensible/string/known-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -89,7 +90,7 @@ def build_string_put_unknown_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/extensible/string/unknown-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -157,13 +158,16 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExtensi map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -213,13 +217,16 @@ def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExten map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -247,10 +254,10 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_known_value_request( content_type=content_type, @@ -301,10 +308,10 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py index 8e4fe4ae6f4..b50a51edba4 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py @@ -106,13 +106,16 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Union[str, _models.DaysOfWeekEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -138,7 +141,7 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekEnum], **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -190,7 +193,7 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekEnum], **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py index ad319066578..569bcf2d620 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py @@ -63,7 +63,7 @@ def build_string_put_known_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/fixed/string/known-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -76,7 +76,7 @@ def build_string_put_unknown_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/fixed/string/unknown-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -144,13 +144,16 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekEnum]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Union[str, _models.DaysOfWeekEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -178,7 +181,7 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -232,7 +235,7 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py index 2d22780ef38..36002ae3e99 100644 --- a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py @@ -120,13 +120,16 @@ async def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -151,10 +154,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_request( content_type=content_type, @@ -245,13 +248,16 @@ async def get(self, **kwargs: Any) -> bool: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.text()) + deserialized = _deserialize(bool, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -276,10 +282,10 @@ async def put(self, body: bool, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_boolean_put_request( content_type=content_type, @@ -370,13 +376,16 @@ async def get(self, **kwargs: Any) -> Any: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Any, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -401,7 +410,7 @@ async def put(self, body: Any, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -495,13 +504,16 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -526,10 +538,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_type_request_body_request( content_type=content_type, @@ -667,13 +679,16 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -698,10 +713,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -870,10 +885,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_verify_verify_request( content_type=content_type, @@ -995,10 +1010,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py index de60340c8e9..115c24376d3 100644 --- a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/operations/_operations.py @@ -45,7 +45,7 @@ def build_string_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/string" @@ -64,7 +64,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/string" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -72,7 +72,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: def build_boolean_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/boolean" @@ -91,7 +91,7 @@ def build_boolean_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/boolean" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -118,7 +118,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/unknown" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -126,7 +126,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: def build_decimal_type_response_body_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/decimal/response_body" @@ -145,7 +145,7 @@ def build_decimal_type_request_body_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal/resquest_body" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -167,7 +167,7 @@ def build_decimal_type_request_parameter_request( # pylint: disable=name-too-lo def build_decimal128_type_response_body_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/decimal128/response_body" @@ -186,7 +186,7 @@ def build_decimal128_type_request_body_request(**kwargs: Any) -> HttpRequest: # _url = "/type/scalar/decimal128/resquest_body" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -227,7 +227,7 @@ def build_decimal_verify_verify_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal/verify" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -254,7 +254,7 @@ def build_decimal128_verify_verify_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal128/verify" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -322,13 +322,16 @@ def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -353,10 +356,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_request( content_type=content_type, @@ -447,13 +450,16 @@ def get(self, **kwargs: Any) -> bool: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.text()) + deserialized = _deserialize(bool, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -478,10 +484,10 @@ def put(self, body: bool, **kwargs: Any) -> None: # pylint: disable=inconsisten _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_boolean_put_request( content_type=content_type, @@ -572,13 +578,16 @@ def get(self, **kwargs: Any) -> Any: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Any, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -603,7 +612,7 @@ def put(self, body: Any, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -697,13 +706,16 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -730,10 +742,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_type_request_body_request( content_type=content_type, @@ -873,13 +885,16 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -906,10 +921,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -1080,10 +1095,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_verify_verify_request( content_type=content_type, @@ -1205,10 +1220,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index 213f6a1617b..4659ba65aa7 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -42,7 +42,7 @@ def build_return_type_changed_from_test_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: str = kwargs.pop("content_type") - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/test" @@ -110,12 +110,15 @@ def test(self, body: str, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index d8ef8e196ea..3b6ecc90cc2 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -92,12 +92,15 @@ async def test(self, body: str, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py index 03954dc7bb8..07065ddab03 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/aio/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -21,6 +22,7 @@ from corehttp.runtime.pipeline import PipelineResponse from corehttp.utils import case_insensitive_dict +from ...._model_base import SdkJSONEncoder from ...._serialization import Deserializer, Serializer from ....aio._configuration import BytesClientConfiguration from ...operations._operations import ( @@ -220,10 +222,10 @@ async def base64(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore _request = build_request_body_base64_request( content_type=content_type, @@ -268,10 +270,10 @@ async def base64_url(self, value: bytes, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore _request = build_request_body_base64_url_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py index e56495b334a..686f32e70fc 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/requestbody/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar @@ -22,6 +23,7 @@ from corehttp.utils import case_insensitive_dict from ..._configuration import BytesClientConfiguration +from ..._model_base import SdkJSONEncoder from ..._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -82,7 +84,7 @@ def build_request_body_base64_request(**kwargs: Any) -> HttpRequest: _url = "/encode/bytes/body/request/base64" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -95,7 +97,7 @@ def build_request_body_base64_url_request(**kwargs: Any) -> HttpRequest: _url = "/encode/bytes/body/request/base64url" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -283,10 +285,10 @@ def base64(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=incons _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64") # type: ignore _request = build_request_body_base64_request( content_type=content_type, @@ -331,10 +333,10 @@ def base64_url(self, value: bytes, **kwargs: Any) -> None: # pylint: disable=in _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = value + _content = json.dumps(value, cls=SdkJSONEncoder, exclude_readonly=True, format="base64url") # type: ignore _request = build_request_body_base64_url_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py index 91881cc5782..be727327064 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/aio/operations/_operations.py @@ -22,6 +22,7 @@ from corehttp.runtime import AsyncPipelineClient from corehttp.runtime.pipeline import PipelineResponse +from ...._model_base import _deserialize from ...._serialization import Deserializer, Serializer from ....aio._configuration import BytesClientConfiguration from ...operations._operations import ( @@ -213,11 +214,11 @@ async def custom_content_type(self, **kwargs: Any) -> AsyncIterator[bytes]: return deserialized # type: ignore - async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: + async def base64(self, **kwargs: Any) -> bytes: """base64. - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: bytes + :rtype: bytes :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -231,7 +232,7 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -242,7 +243,7 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -256,18 +257,24 @@ async def base64(self, **kwargs: Any) -> AsyncIterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: + async def base64_url(self, **kwargs: Any) -> bytes: """base64_url. - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: bytes + :rtype: bytes :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -281,7 +288,7 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -292,7 +299,7 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -306,9 +313,15 @@ async def base64_url(self, **kwargs: Any) -> AsyncIterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py index fd2fac2bab8..61d1c7736f1 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/responsebody/operations/_operations.py @@ -24,6 +24,7 @@ from corehttp.utils import case_insensitive_dict from ..._configuration import BytesClientConfiguration +from ..._model_base import _deserialize from ..._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -82,7 +83,7 @@ def build_response_body_custom_content_type_request(**kwargs: Any) -> HttpReques def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "application/octet-stream") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/encode/bytes/body/response/base64" @@ -96,7 +97,7 @@ def build_response_body_base64_request(**kwargs: Any) -> HttpRequest: def build_response_body_base64_url_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/encode/bytes/body/response/base64url" @@ -280,11 +281,11 @@ def custom_content_type(self, **kwargs: Any) -> Iterator[bytes]: return deserialized # type: ignore - def base64(self, **kwargs: Any) -> Iterator[bytes]: + def base64(self, **kwargs: Any) -> bytes: """base64. - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: bytes + :rtype: bytes :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -298,7 +299,7 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_request( headers=_headers, @@ -309,7 +310,7 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -323,18 +324,24 @@ def base64(self, **kwargs: Any) -> Iterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - def base64_url(self, **kwargs: Any) -> Iterator[bytes]: + def base64_url(self, **kwargs: Any) -> bytes: """base64_url. - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: bytes + :rtype: bytes :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -348,7 +355,7 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[bytes] = kwargs.pop("cls", None) _request = build_response_body_base64_url_request( headers=_headers, @@ -359,7 +366,7 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response @@ -373,9 +380,15 @@ def base64_url(self, **kwargs: Any) -> Iterator[bytes]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(bytes, response.json(), format="base64") if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index 3c284b44606..cb783d52b5d 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Literal, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from corehttp.exceptions import ( ClientAuthenticationError, @@ -14,8 +14,6 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, map_error, ) from corehttp.rest import HttpRequest, HttpResponse @@ -23,7 +21,7 @@ from corehttp.utils import case_insensitive_dict from .. import models as _models -from .._model_base import _deserialize, _failsafe_deserialize +from .._model_base import _failsafe_deserialize from .._serialization import Serializer from .._vendor import StatusCodeRangeClientMixinABC @@ -43,7 +41,7 @@ def build_status_code_range_error_response_status_code_in_range_request( # pyli ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/response/status-code-range/error-response-status-code-in-range" @@ -59,7 +57,7 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/response/status-code-range/error-response-status-code-404" @@ -72,11 +70,13 @@ def build_status_code_range_error_response_status_code404_request( # pylint: di class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): - def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + def error_response_status_code_in_range( # pylint: disable=inconsistent-return-statements + self, **kwargs: Any + ) -> None: """error_response_status_code_in_range. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -90,7 +90,7 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code_in_range_request( headers=_headers, @@ -101,17 +101,12 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if 494 <= response.status_code <= 499: @@ -120,21 +115,14 @@ def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.DefaultError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + def error_response_status_code404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """error_response_status_code404. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -145,7 +133,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code404_request( headers=_headers, @@ -156,17 +144,12 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if response.status_code == 404: @@ -176,12 +159,5 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index 21d4c0a0903..67be147c0ac 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Literal, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from corehttp.exceptions import ( ClientAuthenticationError, @@ -14,15 +14,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, map_error, ) from corehttp.rest import AsyncHttpResponse, HttpRequest from corehttp.runtime.pipeline import PipelineResponse from ... import models as _models -from ..._model_base import _deserialize, _failsafe_deserialize +from ..._model_base import _failsafe_deserialize from ..._operations._operations import ( build_status_code_range_error_response_status_code404_request, build_status_code_range_error_response_status_code_in_range_request, @@ -39,11 +37,11 @@ class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): - async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + async def error_response_status_code_in_range(self, **kwargs: Any) -> None: """error_response_status_code_in_range. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -57,7 +55,7 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code_in_range_request( headers=_headers, @@ -68,19 +66,14 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client.pipeline.run( # type: ignore _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if 494 <= response.status_code <= 499: @@ -89,21 +82,14 @@ async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[20 error = _failsafe_deserialize(_models.DefaultError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + async def error_response_status_code404(self, **kwargs: Any) -> None: """error_response_status_code404. - :return: constant - :rtype: int + :return: None + :rtype: None :raises ~corehttp.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -114,7 +100,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) _request = build_status_code_range_error_response_status_code404_request( headers=_headers, @@ -125,19 +111,14 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client.pipeline.run( # type: ignore _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = None if response.status_code == 404: @@ -147,12 +128,5 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(Literal[204], response.text()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py index 5ddec361988..d73076902fa 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_client.py @@ -7,33 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Union +from typing import Any from typing_extensions import Self from corehttp.rest import HttpRequest, HttpResponse from corehttp.runtime import PipelineClient, policies -from . import models as _models from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin from ._serialization import Deserializer, Serializer -class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class MultipleClient(MultipleClientOperationsMixin): """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any + self, endpoint: str, **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py index 1672af351fb..8ef145f24be 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_configuration.py @@ -6,11 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Union +from typing import Any from corehttp.runtime import policies -from . import models as _models from ._version import VERSION @@ -23,11 +22,14 @@ class MultipleClientConfiguration: :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". - :type api_version: str or ~server.path.multiple.models.Versions + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: + def __init__(self, endpoint: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1.0") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py index 4256b19b695..8066d1b6204 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_client.py @@ -7,33 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Union +from typing import Any, Awaitable from typing_extensions import Self from corehttp.rest import AsyncHttpResponse, HttpRequest from corehttp.runtime import AsyncPipelineClient, policies -from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MultipleClientConfiguration from ._operations import MultipleClientOperationsMixin -class MultipleClient(MultipleClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class MultipleClient(MultipleClientOperationsMixin): """MultipleClient. :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :keyword api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~server.path.multiple.models.Versions """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, endpoint: str, *, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any + self, endpoint: str, **kwargs: Any ) -> None: _endpoint = "{endpoint}/server/path/multiple/{apiVersion}" - self._config = MultipleClientConfiguration(endpoint=endpoint, api_version=api_version, **kwargs) + self._config = MultipleClientConfiguration(endpoint=endpoint, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py index 44ecbfe0751..9f71c626ed6 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/aio/_configuration.py @@ -6,11 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Union +from typing import Any from corehttp.runtime import policies -from .. import models as _models from .._version import VERSION @@ -23,11 +22,14 @@ class MultipleClientConfiguration: :param endpoint: Pass in `http://localhost:3000 `_ for endpoint. Required. :type endpoint: str - :param api_version: Pass in v1.0 for API version. "v1.0" Default value is "v1.0". - :type api_version: str or ~server.path.multiple.models.Versions + :keyword api_version: Pass in v1.0 for API version. Known values are "v1.0" and None. Default + value is "v1.0". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str or ~server.path.multiple.models.Versions """ - def __init__(self, endpoint: str, api_version: Union[str, _models.Versions] = "v1.0", **kwargs: Any) -> None: + def __init__(self, endpoint: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "v1.0") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py index 188e0549d4d..9bf92afaeae 100644 --- a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_operations/_operations.py @@ -41,11 +41,10 @@ def build_versioned_without_api_version_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_api_version_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_query_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-api-version" @@ -55,9 +54,8 @@ def build_versioned_with_query_api_version_request( # pylint: disable=name-too- return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_versioned_with_path_api_version_request( # pylint: disable=name-too-long - api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_path_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + api_version: str = kwargs.pop("api_version", "2022-12-01-preview") # Construct URL _url = "/server/versions/versioned/with-path-api-version/{apiVersion}" path_format_arguments = { @@ -69,11 +67,10 @@ def build_versioned_with_path_api_version_request( # pylint: disable=name-too-l return HttpRequest(method="HEAD", url=_url, **kwargs) -def build_versioned_with_query_old_api_version_request( # pylint: disable=name-too-long - *, api_version: str = "2022-12-01-preview", **kwargs: Any -) -> HttpRequest: +def build_versioned_with_query_old_api_version_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) # Construct URL _url = "/server/versions/versioned/with-query-old-api-version" diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py index 80383534bd9..d28b11f554e 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/aio/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -24,7 +25,7 @@ from corehttp.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import _deserialize +from ..._model_base import SdkJSONEncoder, _deserialize from ..._serialization import Deserializer, Serializer from ...operations._operations import ( build_string_get_known_value_request, @@ -102,13 +103,16 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -155,13 +159,16 @@ async def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWee map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -186,10 +193,10 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekExtensibleEnu _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_known_value_request( content_type=content_type, @@ -235,10 +242,10 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekExtensibleE _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py index a578119dcf7..bb39fbba204 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/operations/_operations.py @@ -5,6 +5,7 @@ # Code generated by Unbranded (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import json import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union @@ -25,7 +26,7 @@ from .. import models as _models from .._configuration import ExtensibleClientConfiguration -from .._model_base import _deserialize +from .._model_base import SdkJSONEncoder, _deserialize from .._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): @@ -42,7 +43,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/enum/extensible/string/known-value" @@ -56,7 +57,7 @@ def build_string_get_known_value_request(**kwargs: Any) -> HttpRequest: def build_string_get_unknown_value_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/enum/extensible/string/unknown-value" @@ -75,7 +76,7 @@ def build_string_put_known_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/extensible/string/known-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -88,7 +89,7 @@ def build_string_put_unknown_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/extensible/string/unknown-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -153,13 +154,16 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExtensi map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -206,13 +210,16 @@ def get_unknown_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekExten map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.text()) + deserialized = _deserialize(Union[str, _models.DaysOfWeekExtensibleEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -239,10 +246,10 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_known_value_request( content_type=content_type, @@ -290,10 +297,10 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_unknown_value_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py index f3ac6bb36db..bad097b1c0d 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/aio/operations/_operations.py @@ -102,13 +102,16 @@ async def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekE map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Union[str, _models.DaysOfWeekEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -133,7 +136,7 @@ async def put_known_value(self, body: Union[str, _models.DaysOfWeekEnum], **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -182,7 +185,7 @@ async def put_unknown_value(self, body: Union[str, _models.DaysOfWeekEnum], **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py index 34f9ce96d42..6fc1d5c9f9e 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/operations/_operations.py @@ -62,7 +62,7 @@ def build_string_put_known_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/fixed/string/known-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -75,7 +75,7 @@ def build_string_put_unknown_value_request(**kwargs: Any) -> HttpRequest: _url = "/type/enum/fixed/string/unknown-value" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -140,13 +140,16 @@ def get_known_value(self, **kwargs: Any) -> Union[str, _models.DaysOfWeekEnum]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Union[str, _models.DaysOfWeekEnum], response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -173,7 +176,7 @@ def put_known_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -224,7 +227,7 @@ def put_unknown_value( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py index 37db2f8fc34..8945ddf2007 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/aio/operations/_operations.py @@ -115,13 +115,16 @@ async def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -145,10 +148,10 @@ async def put(self, body: str, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_request( content_type=content_type, @@ -234,13 +237,16 @@ async def get(self, **kwargs: Any) -> bool: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.text()) + deserialized = _deserialize(bool, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -264,10 +270,10 @@ async def put(self, body: bool, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_boolean_put_request( content_type=content_type, @@ -353,13 +359,16 @@ async def get(self, **kwargs: Any) -> Any: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Any, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -383,7 +392,7 @@ async def put(self, body: Any, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -472,13 +481,16 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -502,10 +514,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_type_request_body_request( content_type=content_type, @@ -635,13 +647,16 @@ async def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -665,10 +680,10 @@ async def request_body(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -828,10 +843,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_verify_verify_request( content_type=content_type, @@ -947,10 +962,10 @@ async def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py index 496a09369c8..10df5ae7059 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/operations/_operations.py @@ -44,7 +44,7 @@ def build_string_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/string" @@ -63,7 +63,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/string" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -71,7 +71,7 @@ def build_string_put_request(**kwargs: Any) -> HttpRequest: def build_boolean_get_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/boolean" @@ -90,7 +90,7 @@ def build_boolean_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/boolean" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -117,7 +117,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/unknown" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -125,7 +125,7 @@ def build_unknown_put_request(**kwargs: Any) -> HttpRequest: def build_decimal_type_response_body_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/decimal/response_body" @@ -144,7 +144,7 @@ def build_decimal_type_request_body_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal/resquest_body" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -166,7 +166,7 @@ def build_decimal_type_request_parameter_request( # pylint: disable=name-too-lo def build_decimal128_type_response_body_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/type/scalar/decimal128/response_body" @@ -185,7 +185,7 @@ def build_decimal128_type_request_body_request(**kwargs: Any) -> HttpRequest: # _url = "/type/scalar/decimal128/resquest_body" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) @@ -226,7 +226,7 @@ def build_decimal_verify_verify_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal/verify" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -253,7 +253,7 @@ def build_decimal128_verify_verify_request(**kwargs: Any) -> HttpRequest: _url = "/type/scalar/decimal128/verify" # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) @@ -318,13 +318,16 @@ def get(self, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -348,10 +351,10 @@ def put(self, body: str, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_string_put_request( content_type=content_type, @@ -437,13 +440,16 @@ def get(self, **kwargs: Any) -> bool: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(bool, response.text()) + deserialized = _deserialize(bool, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -467,10 +473,10 @@ def put(self, body: bool, **kwargs: Any) -> None: # pylint: disable=inconsisten _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_boolean_put_request( content_type=content_type, @@ -556,13 +562,16 @@ def get(self, **kwargs: Any) -> Any: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(Any, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -586,7 +595,7 @@ def put(self, body: Any, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore @@ -675,13 +684,16 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -707,10 +719,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_type_request_body_request( content_type=content_type, @@ -842,13 +854,16 @@ def response_body(self, **kwargs: Any) -> decimal.Decimal: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(decimal.Decimal, response.text()) + deserialized = _deserialize(decimal.Decimal, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -874,10 +889,10 @@ def request_body( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_type_request_body_request( content_type=content_type, @@ -1039,10 +1054,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal_verify_verify_request( content_type=content_type, @@ -1158,10 +1173,10 @@ def verify(self, body: decimal.Decimal, **kwargs: Any) -> None: # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "text/plain")) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/json")) cls: ClsType[None] = kwargs.pop("cls", None) - _content = body + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_decimal128_verify_verify_request( content_type=content_type, diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py index 0b8b9bcc6ff..e864aacbd72 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_operations/_operations.py @@ -41,7 +41,7 @@ def build_return_type_changed_from_test_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: str = kwargs.pop("content_type") - accept = _headers.pop("Accept", "text/plain") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/test" @@ -106,12 +106,15 @@ def test(self, body: str, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index f038487ade4..10bffaa772f 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -89,12 +89,15 @@ async def test(self, body: str, **kwargs: Any) -> str: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(str, response.text()) + deserialized = _deserialize(str, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore From 6986ccc6ad02c6705a418586b237c96389608f2a Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Mar 2025 19:48:09 +0800 Subject: [PATCH 9/9] add changelog --- ...-publish-python-release-2025-2-20-14-38-6.md | 8 -------- ...soft-python-tcgc-0.51.3-2025-2-17-18-4-38.md | 8 -------- .../changes/update-reqs-2025-2-18-11-17-24.md | 7 ------- packages/autorest.python/CHANGELOG.md | 11 +++++++++++ packages/autorest.python/package.json | 6 +++--- packages/typespec-python/CHANGELOG.md | 11 +++++++++++ packages/typespec-python/package.json | 6 +++--- pnpm-lock.yaml | 17 ++++++++--------- 8 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 .chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md delete mode 100644 .chronus/changes/auto-microsoft-python-tcgc-0.51.3-2025-2-17-18-4-38.md delete mode 100644 .chronus/changes/update-reqs-2025-2-18-11-17-24.md diff --git a/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md b/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md deleted file mode 100644 index 82191ef4a5a..00000000000 --- a/.chronus/changes/auto-microsoft-publish-python-release-2025-2-20-14-38-6.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -changeKind: dependencies -packages: - - "@autorest/python" - - "@azure-tools/typespec-python" ---- - -Bump `@typespec/*` 0.67 \ No newline at end of file diff --git a/.chronus/changes/auto-microsoft-python-tcgc-0.51.3-2025-2-17-18-4-38.md b/.chronus/changes/auto-microsoft-python-tcgc-0.51.3-2025-2-17-18-4-38.md deleted file mode 100644 index 743a14a2fd7..00000000000 --- a/.chronus/changes/auto-microsoft-python-tcgc-0.51.3-2025-2-17-18-4-38.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -changeKind: feature -packages: - - "@autorest/python" - - "@azure-tools/typespec-python" ---- - -Support continuation token for paging \ No newline at end of file diff --git a/.chronus/changes/update-reqs-2025-2-18-11-17-24.md b/.chronus/changes/update-reqs-2025-2-18-11-17-24.md deleted file mode 100644 index d65ad602807..00000000000 --- a/.chronus/changes/update-reqs-2025-2-18-11-17-24.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@azure-tools/typespec-python" ---- - -Require node version 20.x \ No newline at end of file diff --git a/packages/autorest.python/CHANGELOG.md b/packages/autorest.python/CHANGELOG.md index 8438d0f1f0f..fda666e890d 100644 --- a/packages/autorest.python/CHANGELOG.md +++ b/packages/autorest.python/CHANGELOG.md @@ -1,5 +1,16 @@ # Release +## 6.30.0 + +### Bump dependencies + +- [#3058](https://github.com/Azure/autorest.python/pull/3058) Bump `@typespec/*` 0.67 + +### Features + +- [#3050](https://github.com/Azure/autorest.python/pull/3050) Support continuation token for paging + + ## 6.29.1 No changes, version bump only. diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 935ecca286d..269c4fc3038 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "6.29.1", + "version": "6.30.0", "description": "The Python extension for generators in AutoRest.", "scripts": { "start": "node ./scripts/run-python3.js ./scripts/start.py", @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", + "@typespec/http-client-python": "~0.8.1", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} \ No newline at end of file +} diff --git a/packages/typespec-python/CHANGELOG.md b/packages/typespec-python/CHANGELOG.md index 0e3145f39b0..42baca6aad0 100644 --- a/packages/typespec-python/CHANGELOG.md +++ b/packages/typespec-python/CHANGELOG.md @@ -1,5 +1,16 @@ # Release +## 0.40.0 + +### Bump dependencies + +- [#3058](https://github.com/Azure/autorest.python/pull/3058) Bump `@typespec/*` 0.67 + +### Features + +- [#3050](https://github.com/Azure/autorest.python/pull/3050) Support continuation token for paging + + ## 0.39.1 ### Bug Fixes diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 4f61ef69ecd..ea0762d84f8 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-python", - "version": "0.39.1", + "version": "0.40.0", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://github.com/Azure/autorest.python", @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz", + "@typespec/http-client-python": "~0.8.1", "fs-extra": "~11.2.0" }, "devDependencies": { @@ -89,4 +89,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 632651d4d03..9e1f3b2a59e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju) + specifier: ~0.8.1 + version: 0.8.1(xyfohv7glp6msr4ipudj2mb5ju) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea) + specifier: ~0.8.1 + version: 0.8.1(z4b5mqrksjtjtkrtw4eaa2rjea) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1535,9 +1535,8 @@ packages: peerDependencies: '@typespec/compiler': ^0.67.1 - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz} - version: 0.8.1 + '@typespec/http-client-python@0.8.1': + resolution: {integrity: sha512-OeSO54sFSfR6/Gkny0S3UJTHrXYwfRcaMJf94uBnTUgo5r9QZSBj2BXjNfW4opOvyZ3S7m5ozRQVp9LAMz8suQ==} engines: {node: '>=18.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.53.0 <1.0.0' @@ -6144,7 +6143,7 @@ snapshots: dependencies: '@typespec/compiler': 0.67.1(@types/node@22.5.5) - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(xyfohv7glp6msr4ipudj2mb5ju)': + '@typespec/http-client-python@0.8.1(xyfohv7glp6msr4ipudj2mb5ju)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(nzqsibdudqbld3r7bpinzdupvm) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.13.10))))) @@ -6165,7 +6164,7 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDY3MTc2OS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.8.1.tgz(z4b5mqrksjtjtkrtw4eaa2rjea)': + '@typespec/http-client-python@0.8.1(z4b5mqrksjtjtkrtw4eaa2rjea)': dependencies: '@azure-tools/typespec-autorest': 0.53.0(vsru7ipd7qt42slknz5aanwsou) '@azure-tools/typespec-azure-core': 0.53.0(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))))(@typespec/rest@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/http@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5))(@typespec/streams@0.67.1(@typespec/compiler@0.67.1(@types/node@22.5.5)))))