From 4a3f8cd4736ba3ac56e1841d1e480638ab3e8a02 Mon Sep 17 00:00:00 2001 From: Jorge Rangel <102122018+jorgerangel-msft@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:59:57 -0500 Subject: [PATCH 01/29] fix: do not unintentially walk non-root enum types (#10935) fixes: https://github.com/microsoft/typespec/issues/10932 --- .../ModelSerializationExtensionsDefinition.cs | 19 ++++++++++++++----- .../src/Generated/Models/DogKind.cs | 2 +- .../src/Generated/Models/SnakeKind.cs | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs index f1c22d729e2..34cfb90210c 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs @@ -211,14 +211,14 @@ protected override SuppressionStatement[] BuildDisabledFileWarnings() : []; private bool HasFileBinaryContentJsonModel - => _hasFileBinaryContentJsonModel ??= HasFileBinaryContentModelForUsage(InputModelTypeUsage.Json); + => _hasFileBinaryContentJsonModel ??= HasFileTypeForUsage(InputModelTypeUsage.Json); private bool? _hasFileBinaryContentJsonModel; private bool HasFileBinaryContentXmlModel - => _hasFileBinaryContentXmlModel ??= HasFileBinaryContentModelForUsage(InputModelTypeUsage.Xml); + => _hasFileBinaryContentXmlModel ??= HasFileTypeForUsage(InputModelTypeUsage.Xml); private bool? _hasFileBinaryContentXmlModel; - private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) + private static bool HasFileTypeForUsage(InputModelTypeUsage usage) { foreach (var model in ScmCodeModelGenerator.Instance.InputLibrary.InputNamespace.Models) { @@ -229,8 +229,7 @@ private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) foreach (var property in model.Properties) { - var propertyType = ScmCodeModelGenerator.Instance.TypeFactory.CreateCSharpType(property.Type); - if (propertyType != null && ScmModelProvider.IsFileBinaryContentType(propertyType)) + if (IsFileInputType(property.Type)) { return true; } @@ -240,6 +239,16 @@ private static bool HasFileBinaryContentModelForUsage(InputModelTypeUsage usage) return false; } + private static bool IsFileInputType(InputType type) => type switch + { + InputModelType { IsFileType: true } => true, + InputPrimitiveType { IsFileType: true } => true, + InputArrayType array => IsFileInputType(array.ValueType), + InputDictionaryType dictionary => IsFileInputType(dictionary.ValueType), + InputNullableType nullable => IsFileInputType(nullable.Type), + _ => false, + }; + private MethodProvider BuildWriteFileBinaryContentMethodProvider() { var valueParameter = new ParameterProvider("value", FormattableStringHelpers.Empty, typeof(FileBinaryContent)); diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs index 08c207dedc0..bc84debea39 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/DogKind.cs @@ -7,7 +7,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator { - public readonly partial struct DogKind : IEquatable + internal readonly partial struct DogKind : IEquatable { public DogKind(string value) => throw null; diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs index 8e678733c92..351935ee0ca 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/enum-discriminator/src/Generated/Models/SnakeKind.cs @@ -4,7 +4,7 @@ namespace _Type.Model.Inheritance.EnumDiscriminator { - public enum SnakeKind + internal enum SnakeKind { /// Species cobra. Cobra From 5f94e61daf0ad036d7c3e112fe1ae53ca3068a2b Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 13:32:28 +0800 Subject: [PATCH 02/29] [python] Add mock_api coverage for single-discriminator no-subtypes and body-root nested scenarios (#10896) This adds python mock API coverage for new Spector scenarios introduced by the cross-language spec updates (PR #10841): a discriminated model with no declared subtypes, and a `@bodyRoot` parameter nested inside a wrapper model. The PR extends existing single-discriminator tests in both sync and async suites, adds new shared body-root tests, and aligns local spec inputs to a version that contains the scenarios. - **Test coverage: single-discriminator no-subtypes (shared sync/async)** - Extended existing shared tests to cover: - `get_no_subtypes_model()` - `put_no_subtypes_model(...)` - Added `Fish` model assertions to validate the expected wire payload shape (`kind`, `size`). - **Test coverage: body-root nested (shared sync/async)** - Added new shared tests (`test_parameters_body_root.py` and `asynctests/test_parameters_body_root_async.py`) covering the `nested(...)` operation with a `BodyRootModel` (`category`, `link_type`, `was_successful`). - Validated locally against the Spector mock server. - **Spec dependency update for scenario availability** - Updated `@typespec/http-specs` in `packages/http-client-python/package.json` (and lockfile) to a version containing the new scenario definitions used by regeneration. - **Change tracking** - Added a Chronus `internal` entry for `@typespec/http-client-python`. ```python def test_get_no_subtypes_model(client): assert client.get_no_subtypes_model() == Fish(kind="salmon", size=10) def test_put_no_subtypes_model(client): client.put_no_subtypes_model(Fish(kind="salmon", size=10)) def test_nested(client): client.nested(BodyRootModel(category="widget", link_type="hard", was_successful=True)) ``` > Note: The third scenario from PR #10841, `Parameters_Query_SpecialChar_dollarSign`, is intentionally **not** covered. There is an upstream spec inconsistency where `main.tsp` declares `@route("/dollarSign")` (camelCase) while `mockapi.ts` registers the endpoint at `/dollar-sign` (kebab-case). The mock server only serves `/dollar-sign`, while the generated SDK correctly calls `/dollarSign`, so the test would 404. This requires a fix in `@typespec/http-specs` before SDK coverage can pass. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan --- ...ator-no-subtypes-tests-2026-6-4-23-29-0.md | 7 ++++++ packages/http-client-python/package-lock.json | 22 +++++++++---------- packages/http-client-python/package.json | 2 +- .../test_parameters_body_root_async.py | 20 +++++++++++++++++ ..._inheritance_single_discriminator_async.py | 12 +++++++++- .../shared/test_parameters_body_root.py | 18 +++++++++++++++ ..._model_inheritance_single_discriminator.py | 10 ++++++++- 7 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 .chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md create mode 100644 packages/http-client-python/tests/mock_api/shared/asynctests/test_parameters_body_root_async.py create mode 100644 packages/http-client-python/tests/mock_api/shared/test_parameters_body_root.py diff --git a/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md b/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md new file mode 100644 index 00000000000..ad64f253038 --- /dev/null +++ b/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the single-discriminator no-subtypes and body-root nested Spector scenarios from http-specs. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 21cc5c3d26b..0e11eaaf605 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.12.0", "@typespec/events": "~0.82.0", "@typespec/http": "^1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", + "@typespec/http-specs": "0.1.0-alpha.38-dev.1", "@typespec/openapi": "^1.12.0", "@typespec/rest": "~0.82.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2529,24 +2529,24 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.37", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37.tgz", - "integrity": "sha512-XOIr51yuGVGMjr83OlpaeXWv2CSV+nnFZl8+Evws/M3DZfpQhMmbl7bSVYu378kCjFCw2JNLlob9e3fzJxaNdg==", + "version": "0.1.0-alpha.38-dev.1", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38-dev.1.tgz", + "integrity": "sha512-FqvLW1nM5P0WBvA5TTghgrrxPYLPsjFA4fN4V4mKumuBDG4ty3+KjBpJvFZE3GVCIsXQqP+sF08YzC5nG3iV+g==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25" + "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.0", + "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.0" }, "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@typespec/compiler": "^1.12.0 || >= 1.13.0-dev.12", + "@typespec/http": "^1.12.0 || >= 1.13.0-dev.0", + "@typespec/rest": "^0.82.0 || >= 0.83.0-dev.0", + "@typespec/versioning": "^0.82.0 || >= 0.83.0-dev.0", + "@typespec/xml": "^0.82.0 || >= 0.83.0-dev.0" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 8d01a7f63e6..696ffe46cd2 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -115,7 +115,7 @@ "@typespec/sse": "~0.82.0", "@typespec/streams": "~0.82.0", "@typespec/xml": "~0.82.0", - "@typespec/http-specs": "0.1.0-alpha.37", + "@typespec/http-specs": "0.1.0-alpha.38-dev.1", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_parameters_body_root_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_parameters_body_root_async.py new file mode 100644 index 00000000000..3b8a87cdbfa --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_parameters_body_root_async.py @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from parameters.bodyroot.aio import BodyRootClient +from parameters.bodyroot.models import BodyRootModel + + +@pytest_asyncio.fixture +async def client(): + async with BodyRootClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_nested(client: BodyRootClient): + await client.nested(BodyRootModel(category="widget", link_type="hard", was_successful=True)) diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py index e6ddd9c44fc..5c7a211edbe 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py @@ -6,7 +6,7 @@ import pytest import pytest_asyncio from typetest.model.singlediscriminator.aio import SingleDiscriminatorClient -from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur +from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur, Fish @pytest_asyncio.fixture @@ -63,6 +63,16 @@ async def test_get_wrong_discriminator(client): assert await client.get_wrong_discriminator() == Bird(wingspan=1, kind="wrongKind") +@pytest.mark.asyncio +async def test_get_no_subtypes_model(client): + assert await client.get_no_subtypes_model() == Fish(kind="salmon", size=10) + + +@pytest.mark.asyncio +async def test_put_no_subtypes_model(client): + await client.put_no_subtypes_model(Fish(kind="salmon", size=10)) + + @pytest.mark.asyncio async def test_get_legacy_model(client): assert await client.get_legacy_model() == Dinosaur(size=20, kind="t-rex") diff --git a/packages/http-client-python/tests/mock_api/shared/test_parameters_body_root.py b/packages/http-client-python/tests/mock_api/shared/test_parameters_body_root.py new file mode 100644 index 00000000000..0b889e058d8 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_parameters_body_root.py @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from parameters.bodyroot import BodyRootClient +from parameters.bodyroot.models import BodyRootModel + + +@pytest.fixture +def client(): + with BodyRootClient() as client: + yield client + + +def test_nested(client: BodyRootClient): + client.nested(BodyRootModel(category="widget", link_type="hard", was_successful=True)) diff --git a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py index 86435d5486d..d83894d6750 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py +++ b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- import pytest from typetest.model.singlediscriminator import SingleDiscriminatorClient -from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur +from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur, Fish @pytest.fixture @@ -56,5 +56,13 @@ def test_get_wrong_discriminator(client): assert client.get_wrong_discriminator() == Bird(wingspan=1, kind="wrongKind") +def test_get_no_subtypes_model(client): + assert client.get_no_subtypes_model() == Fish(kind="salmon", size=10) + + +def test_put_no_subtypes_model(client): + client.put_no_subtypes_model(Fish(kind="salmon", size=10)) + + def test_get_legacy_model(client): assert client.get_legacy_model() == Dinosaur(size=20, kind="t-rex") From 99197b74cc42f3279114e085da4e8d712df3d924 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 05:32:44 +0000 Subject: [PATCH 03/29] [python] Add test for client-doc spector scenario (Azure typespec-azure #4268) (#10888) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds python SDK mock_api coverage for the spector cases introduced in Azure/typespec-azure#4268. Of the two new scenarios under `azure/client-generator-core/`, only `client-doc` is generatable by the python emitter (`response-as-bool` is already in `SKIP_SPECS`). ### Changes - **Tests** — sync + async tests for the `@clientDoc` scenario: - `harvest` POST round-trip against the mock server. - `@clientDoc` **append** mode: `Plant` model docstring retains base doc and appends client-specific text. - `@clientDoc` **replace** mode: `harvest` operation docstring fully overrides the base doc. - Docstring assertions compare only the method/model description (extracted via `split(":ivar")[0].strip()` for the model and `split(":param")[0].strip()` for the operation), excluding the parameter docstrings. - **Changelog** — `internal` chronus entry for `@typespec/http-client-python`. `response-as-bool` is intentionally skipped in the emitter regeneration config, so no client is generated and no test is added for it. ```python def test_harvest(client: ClientDocClient): body = models.Plant(name="Rose", species="Rosa") assert client.documentation.harvest(body) == body def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. doc = models.Plant.__doc__.split(":ivar")[0].strip() assert doc == "A plant in the garden. This model is used to represent a plant in the client SDK." def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. doc = client.documentation.harvest.__doc__.split(":param")[0].strip() assert doc == "Retrieves a plant from the garden by submitting its name." ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan --- .../python-client-doc-test-2026-6-4-9-30-0.md | 7 ++++ ..._client_generator_core_client_doc_async.py | 36 +++++++++++++++++++ ..._azure_client_generator_core_client_doc.py | 33 +++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 .chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py diff --git a/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md b/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md new file mode 100644 index 00000000000..84dd98fac83 --- /dev/null +++ b/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test for the `@clientDoc` decorator spector case (azure/client-generator-core/client-doc). diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py new file mode 100644 index 00000000000..ee0c114ec5e --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.clientdoc.aio import ClientDocClient +from specs.azure.clientgenerator.core.clientdoc import models + + +@pytest_asyncio.fixture +async def client(): + async with ClientDocClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_harvest(client: ClientDocClient): + body = models.Plant(name="Rose", species="Rosa") + assert await client.documentation.harvest(body) == body + + +def test_model_doc_appended(): + # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + # Only the model description is compared, not the parameter docstrings. + doc = models.Plant.__doc__.split(":ivar")[0].strip() + assert doc == "A plant in the garden. This model is used to represent a plant in the client SDK." + + +@pytest.mark.asyncio +async def test_operation_doc_replaced(client: ClientDocClient): + # @clientDoc in replace mode overrides the base @doc completely. + # Only the operation description is compared, not the parameter docstrings. + doc = client.documentation.harvest.__doc__.split(":param")[0].strip() + assert doc == "Retrieves a plant from the garden by submitting its name." diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py new file mode 100644 index 00000000000..edc5575f2f0 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py @@ -0,0 +1,33 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from specs.azure.clientgenerator.core.clientdoc import ClientDocClient +from specs.azure.clientgenerator.core.clientdoc import models + + +@pytest.fixture +def client(): + with ClientDocClient() as client: + yield client + + +def test_harvest(client: ClientDocClient): + body = models.Plant(name="Rose", species="Rosa") + assert client.documentation.harvest(body) == body + + +def test_model_doc_appended(): + # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + # Only the model description is compared, not the parameter docstrings. + doc = models.Plant.__doc__.split(":ivar")[0].strip() + assert doc == "A plant in the garden. This model is used to represent a plant in the client SDK." + + +def test_operation_doc_replaced(client: ClientDocClient): + # @clientDoc in replace mode overrides the base @doc completely. + # Only the operation description is compared, not the parameter docstrings. + doc = client.documentation.harvest.__doc__.split(":param")[0].strip() + assert doc == "Retrieves a plant from the garden by submitting its name." From 31cb717e779a21fd2e1bcf17fb5613d549164ed5 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 17:26:19 +0800 Subject: [PATCH 04/29] [python] Add mock API test (#10944) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...e-type-mock-api-test-2026-5-12-23-16-00.md | 7 ++ ...ibility-head-model-test-2026-5-4-23-8-9.md | 7 ++ ...oad-head-python-test-2026-4-17-22-55-53.md | 7 ++ ...-response-as-bool-test-2026-6-10-5-33-0.md | 7 ++ ...tion-body-params-test-2026-4-28-23-10-0.md | 7 ++ ...usage-namespace-test-2026-5-26-23-18-25.md | 7 ++ cspell.yaml | 1 + .../eng/scripts/ci/regenerate-common.ts | 7 +- ...ent_generator_core_alternate_type_async.py | 74 +++++++++++++++++++ ...t_generator_core_response_as_bool_async.py | 24 ++++++ ...azure_client_generator_core_usage_async.py | 6 ++ .../asynctests/test_special_words_async.py | 5 ++ ...re_client_generator_core_alternate_type.py | 69 +++++++++++++++++ ..._client_generator_core_response_as_bool.py | 21 ++++++ .../test_azure_client_generator_core_usage.py | 9 +++ .../mock_api/azure/test_special_words.py | 4 + .../asynctests/test_payload_head_async.py | 26 +++++++ .../test_typetest_model_visibility_async.py | 5 ++ .../mock_api/shared/test_payload_head.py | 23 ++++++ .../shared/test_typetest_model_visibility.py | 4 + .../asynctests/test_special_words_async.py | 5 ++ .../mock_api/unbranded/test_special_words.py | 4 + 22 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 .chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md create mode 100644 .chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md create mode 100644 .chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md create mode 100644 .chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md create mode 100644 .chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md create mode 100644 .chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py create mode 100644 packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py create mode 100644 packages/http-client-python/tests/mock_api/shared/test_payload_head.py diff --git a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md new file mode 100644 index 00000000000..47ce56ebe73 --- /dev/null +++ b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock API tests for the azure/client-generator-core/alternate-type Spector scenario diff --git a/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md b/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md new file mode 100644 index 00000000000..26893a4c4dc --- /dev/null +++ b/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test coverage for `headModel` scenario in `type/model/visibility` spec. diff --git a/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md new file mode 100644 index 00000000000..ee198e709bd --- /dev/null +++ b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test for `payload/head` scenario with `Content-Type` and `x-ms-meta` response headers. diff --git a/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md b/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md new file mode 100644 index 00000000000..9c5937cf445 --- /dev/null +++ b/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock api test for azure client-generator-core response-as-bool spector case diff --git a/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md b/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md new file mode 100644 index 00000000000..ad10ee1042b --- /dev/null +++ b/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test cases for operation body parameters with reserved names (e.g., `items`) to verify the wire name is not mangled. diff --git a/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md b/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md new file mode 100644 index 00000000000..255a67569a5 --- /dev/null +++ b/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock API tests for the Azure client-generator-core usage namespace usage scenario from azure-http-specs. diff --git a/cspell.yaml b/cspell.yaml index 58ec6e0489f..42cc56da89c 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -238,6 +238,7 @@ words: - reinjected - repr - respecify + - responseasbool - rjust - rollup - rpaas diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 1fe6f17d63c..ded02b8ef50 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -70,11 +70,7 @@ export interface BuildTaskGroupsOptions { // ---- Public constants ---- -export const SKIP_SPECS: string[] = [ - "type/file", - "service/multiple-services", - "azure/client-generator-core/response-as-bool", -]; +export const SKIP_SPECS: string[] = ["type/file", "service/multiple-services"]; export const SpecialFlags: Record> = { azure: { @@ -728,6 +724,7 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P "azure/generation-subdir2", "unbranded/generation-subdir", "unbranded/generation-subdir2", + "azure/azure-client-generator-core-alternate-type", ]; const sourceRoot = join(tempDir, ...sourceSubdir.split("/")); diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py new file mode 100644 index 00000000000..30f453723e1 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py @@ -0,0 +1,74 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +import geojson +from specs.azure.clientgenerator.core.alternatetype.aio import AlternateTypeClient +from specs.azure.clientgenerator.core.alternatetype import models + +# Shared test data +PROPERTIES = {"name": "A single point of interest", "category": "landmark", "elevation": 100} + +GEOMETRY = geojson.Point((-122.25, 37.87)) + +FEATURE_ID = "feature-1" + + +@pytest_asyncio.fixture +async def client(): + async with AlternateTypeClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.fixture +def feature_geojson(): + """Shared GeoJSON Feature for tests.""" + return geojson.Feature(type="Feature", geometry=GEOMETRY, properties=PROPERTIES, id=FEATURE_ID) + + +@pytest.mark.asyncio +async def test_external_type_get_model(client: AlternateTypeClient): + """Test getting a Feature object with geometry, properties, and optional id fields.""" + result = await client.external_type.get_model() + + # Validate the response structure based on the TypeSpec example + assert result.type == "Feature" + assert result.geometry.type == "Point" + assert result.geometry.coordinates == [-122.25, 37.87] + assert result.properties == PROPERTIES + assert result.id == FEATURE_ID + + +@pytest.mark.asyncio +async def test_external_type_put_model(client: AlternateTypeClient, feature_geojson): + """Test putting a Feature object in request body.""" + # Should return None (204/empty response) + result = await client.external_type.put_model(body=feature_geojson) + assert result is None + + +@pytest.mark.asyncio +async def test_external_type_get_property(client: AlternateTypeClient): + """Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields.""" + result = await client.external_type.get_property() + + # Validate the response structure based on the TypeSpec example + assert result.feature.type == "Feature" + assert result.feature.geometry.type == "Point" + assert result.feature.geometry.coordinates == [-122.25, 37.87] + assert result.feature.properties == PROPERTIES + assert result.feature.id == FEATURE_ID + assert result.additional_property == "extra" + + +@pytest.mark.asyncio +async def test_external_type_put_property(client: AlternateTypeClient, feature_geojson): + """Test putting a ModelWithFeatureProperty object in request body.""" + model_with_feature = models.ModelWithFeatureProperty(feature=feature_geojson, additional_property="extra") + + # Should return None (204/empty response) + result = await client.external_type.put_property(body=model_with_feature) + assert result is None diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py new file mode 100644 index 00000000000..9df21cc96d8 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py @@ -0,0 +1,24 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.responseasbool.aio import ResponseAsBoolClient + + +@pytest_asyncio.fixture +async def client(): + async with ResponseAsBoolClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_exists(client: ResponseAsBoolClient): + assert await client.head_as_boolean.exists() is True + + +@pytest.mark.asyncio +async def test_not_exists(client: ResponseAsBoolClient): + assert await client.head_as_boolean.not_exists() is False diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py index 816279eeb94..9a82c7e573a 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py @@ -37,3 +37,9 @@ async def test_orphan_model_serializable(client: UsageClient): await client.model_in_operation.orphan_model_serializable( body=models.OrphanModel(model_name="name", description="desc") ) + + +@pytest.mark.asyncio +async def test_namespace_model_serializable(client: UsageClient): + namespace_model = models.NamespaceModel(name="test") + await client.namespace_usage.namespace_model_serializable(body=namespace_model) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py index 8c59ea05070..78650db138d 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py @@ -70,3 +70,8 @@ async def test_model_properties_with_list(client: SpecialWordsClient): async def test_extensible_strings(client: SpecialWordsClient): for enum_value in models.ExtensibleString: assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) + + +@pytest.mark.asyncio +async def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + await client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py new file mode 100644 index 00000000000..c5ae3266c87 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py @@ -0,0 +1,69 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import geojson +from specs.azure.clientgenerator.core.alternatetype import AlternateTypeClient +from specs.azure.clientgenerator.core.alternatetype import models + +# Shared test data +PROPERTIES = {"name": "A single point of interest", "category": "landmark", "elevation": 100} + +GEOMETRY = geojson.Point((-122.25, 37.87)) + +FEATURE_ID = "feature-1" + + +@pytest.fixture +def client(): + with AlternateTypeClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.fixture +def feature_geojson(): + """Shared GeoJSON Feature for tests.""" + return geojson.Feature(type="Feature", geometry=GEOMETRY, properties=PROPERTIES, id=FEATURE_ID) + + +def test_external_type_get_model(client: AlternateTypeClient): + """Test getting a Feature object with geometry, properties, and optional id fields.""" + result = client.external_type.get_model() + + # Validate the response structure based on the TypeSpec example + assert result.type == "Feature" + assert result.geometry.type == "Point" + assert result.geometry.coordinates == [-122.25, 37.87] + assert result.properties == PROPERTIES + assert result.id == FEATURE_ID + + +def test_external_type_put_model(client: AlternateTypeClient, feature_geojson): + """Test putting a Feature object in request body.""" + # Should return None (204/empty response) + result = client.external_type.put_model(body=feature_geojson) + assert result is None + + +def test_external_type_get_property(client: AlternateTypeClient): + """Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields.""" + result = client.external_type.get_property() + + # Validate the response structure based on the TypeSpec example + assert result.feature.type == "Feature" + assert result.feature.geometry.type == "Point" + assert result.feature.geometry.coordinates == [-122.25, 37.87] + assert result.feature.properties == PROPERTIES + assert result.feature.id == FEATURE_ID + assert result.additional_property == "extra" + + +def test_external_type_put_property(client: AlternateTypeClient, feature_geojson): + """Test putting a ModelWithFeatureProperty object in request body.""" + model_with_feature = models.ModelWithFeatureProperty(feature=feature_geojson, additional_property="extra") + + # Should return None (204/empty response) + result = client.external_type.put_property(body=model_with_feature) + assert result is None diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py new file mode 100644 index 00000000000..e37a641ce11 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from specs.azure.clientgenerator.core.responseasbool import ResponseAsBoolClient + + +@pytest.fixture +def client(): + with ResponseAsBoolClient() as client: + yield client + + +def test_exists(client: ResponseAsBoolClient): + assert client.head_as_boolean.exists() is True + + +def test_not_exists(client: ResponseAsBoolClient): + assert client.head_as_boolean.not_exists() is False diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py index 0094bef89a1..f40f64041eb 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py @@ -30,3 +30,12 @@ def test_model_usage(client: UsageClient): def test_orphan_model_serializable(client: UsageClient): client.model_in_operation.orphan_model_serializable(body=models.OrphanModel(model_name="name", description="desc")) + + +def test_namespace_model_serializable(client: UsageClient): + namespace_model = models.NamespaceModel(name="test") + client.namespace_usage.namespace_model_serializable(body=namespace_model) + +def test_import(): + # NestedNamespaceModel shall be exposed + from specs.azure.clientgenerator.core.usage.models import NestedNamespaceModel diff --git a/packages/http-client-python/tests/mock_api/azure/test_special_words.py b/packages/http-client-python/tests/mock_api/azure/test_special_words.py index ab23b59409f..234301dede1 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_special_words.py +++ b/packages/http-client-python/tests/mock_api/azure/test_special_words.py @@ -61,3 +61,7 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in models.ExtensibleString: assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) + + +def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py new file mode 100644 index 00000000000..0b24e996530 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from payload.head.aio import HeadClient + + +@pytest_asyncio.fixture +async def client(): + async with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.mark.asyncio +async def test_content_type_header_in_response(client: HeadClient): + assert await client.content_type_header_in_response() is True + + +@pytest.mark.asyncio +async def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = await client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello" diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py index 62827695819..d5038fcd7de 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py @@ -21,6 +21,11 @@ async def test_get_model(client): assert result == models.VisibilityModel(read_prop="abc") +@pytest.mark.asyncio +async def test_head_model(client): + assert await client.head_model(models.VisibilityModel(), query_prop=123) + + @pytest.mark.asyncio async def test_put_model(client): await client.put_model(models.VisibilityModel(create_prop=["foo", "bar"], update_prop=[1, 2])) diff --git a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py new file mode 100644 index 00000000000..86464d56b2d --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from payload.head import HeadClient + + +@pytest.fixture +def client(): + with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +def test_content_type_header_in_response(client: HeadClient): + assert client.content_type_header_in_response() is True + + +def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello" diff --git a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py index c6f4695f2fa..ddbe78d2e3e 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py +++ b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py @@ -18,6 +18,10 @@ def test_get_model(client): assert result == models.VisibilityModel(read_prop="abc") +def test_head_model(client): + assert client.head_model(models.VisibilityModel(), query_prop=123) + + def test_put_model(client): client.put_model(models.VisibilityModel(create_prop=["foo", "bar"], update_prop=[1, 2])) diff --git a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py index c1e3bc0a8f2..5b8dcebaf1f 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py +++ b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py @@ -72,3 +72,8 @@ async def test_model_properties_with_list(client: SpecialWordsClient): async def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) + + +@pytest.mark.asyncio +async def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + await client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py b/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py index 83269cc1e47..9da0330a805 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py +++ b/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py @@ -64,3 +64,7 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) + + +def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + client.reserved_operation_body_params.with_items(items=["item"]) From 132f4457836703fd341bc7b130844a4ef64cc0b8 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 11 Jun 2026 01:09:47 +0800 Subject: [PATCH 05/29] [python] release new version for latest tsp version (#10948) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...e-type-mock-api-test-2026-5-12-23-16-00.md | 7 - ...ltiple-services-tests-2026-6-10-8-56-11.md | 7 + ...ator-no-subtypes-tests-2026-6-4-23-29-0.md | 7 - ...ibility-head-model-test-2026-5-4-23-8-9.md | 7 - ...oad-head-python-test-2026-4-17-22-55-53.md | 7 - ...sourceidentifier-tests-2026-6-10-8-52-0.md | 7 + ...-response-as-bool-test-2026-6-10-5-33-0.md | 7 - .../python-client-doc-test-2026-6-4-9-30-0.md | 7 - ...tion-body-params-test-2026-4-28-23-10-0.md | 7 - ...usage-namespace-test-2026-5-26-23-18-25.md | 7 - cspell.yaml | 3 + packages/http-client-python/CHANGELOG.md | 6 + .../eng/scripts/ci/regenerate-common.ts | 2 +- packages/http-client-python/package-lock.json | 282 +++++++++--------- packages/http-client-python/package.json | 62 ++-- .../test_azure_arm_commonproperties_async.py | 41 +++ .../test_azure_arm_managementgroup_async.py | 82 +++++ .../test_service_multiple_services_async.py | 41 +++ .../azure/test_azure_arm_commonproperties.py | 39 +++ .../azure/test_azure_arm_managementgroup.py | 71 +++++ .../azure/test_service_multiple_services.py | 36 +++ 21 files changed, 506 insertions(+), 229 deletions(-) delete mode 100644 .chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md create mode 100644 .chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md delete mode 100644 .chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md delete mode 100644 .chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md delete mode 100644 .chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md create mode 100644 .chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md delete mode 100644 .chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md delete mode 100644 .chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md delete mode 100644 .chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md delete mode 100644 .chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_managementgroup_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_arm_managementgroup.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py diff --git a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md deleted file mode 100644 index 47ce56ebe73..00000000000 --- a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add sync and async mock API tests for the azure/client-generator-core/alternate-type Spector scenario diff --git a/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md new file mode 100644 index 00000000000..14c091683a4 --- /dev/null +++ b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the `service/multiple-services` Spector scenario and enable its regeneration. diff --git a/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md b/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md deleted file mode 100644 index ad64f253038..00000000000 --- a/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add sync and async mock_api tests for the single-discriminator no-subtypes and body-root nested Spector scenarios from http-specs. diff --git a/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md b/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md deleted file mode 100644 index 26893a4c4dc..00000000000 --- a/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add test coverage for `headModel` scenario in `type/model/visibility` spec. diff --git a/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md deleted file mode 100644 index ee198e709bd..00000000000 --- a/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add mock API test for `payload/head` scenario with `Content-Type` and `x-ms-meta` response headers. diff --git a/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md b/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md new file mode 100644 index 00000000000..d116b0ad28e --- /dev/null +++ b/.chronus/changes/python-add-arm-managementgroup-armresourceidentifier-tests-2026-6-10-8-52-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the management group scoped resources and ARM resource identifier Spector scenarios from azure-http-specs. diff --git a/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md b/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md deleted file mode 100644 index 9c5937cf445..00000000000 --- a/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add mock api test for azure client-generator-core response-as-bool spector case diff --git a/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md b/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md deleted file mode 100644 index 84dd98fac83..00000000000 --- a/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add test for the `@clientDoc` decorator spector case (azure/client-generator-core/client-doc). diff --git a/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md b/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md deleted file mode 100644 index ad10ee1042b..00000000000 --- a/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add mock API test cases for operation body parameters with reserved names (e.g., `items`) to verify the wire name is not mangled. diff --git a/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md b/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md deleted file mode 100644 index 255a67569a5..00000000000 --- a/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add sync and async mock API tests for the Azure client-generator-core usage namespace usage scenario from azure-http-specs. diff --git a/cspell.yaml b/cspell.yaml index 42cc56da89c..d2e086c1875 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -251,6 +251,8 @@ words: - sdkcore - segmentof - serde + - servicea + - serviceb - setuppy - sfixed - shiki @@ -308,6 +310,7 @@ words: - venvtools - VITE - vitest + - vnet - VNEXT - vsix - vsmarketplace diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 9bc37e53db5..c07dbe104c3 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @typespec/http-client-python +## 0.31.1 + +### Bump dependencies + +- Bump dependencies of `@typespec/*` and `@azure-tools/*` to latest versions + ## 0.31.0 ### Features diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index ded02b8ef50..9b2defd0e8c 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -70,7 +70,7 @@ export interface BuildTaskGroupsOptions { // ---- Public constants ---- -export const SKIP_SPECS: string[] = ["type/file", "service/multiple-services"]; +export const SKIP_SPECS: string[] = ["type/file"]; export const SpecialFlags: Record> = { azure: { diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 0e11eaaf605..5ad0d57671f 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-python", - "version": "0.31.0", + "version": "0.31.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-python", - "version": "0.31.0", + "version": "0.31.1", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -17,27 +17,27 @@ "tsx": "^4.21.0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.42-dev.0", - "@azure-tools/typespec-autorest": "~0.68.0", - "@azure-tools/typespec-azure-core": "~0.68.0", - "@azure-tools/typespec-azure-resource-manager": "~0.68.0", - "@azure-tools/typespec-azure-rulesets": "~0.68.0", - "@azure-tools/typespec-client-generator-core": "~0.68.4", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@azure-tools/typespec-autorest": "~0.69.0", + "@azure-tools/typespec-azure-core": "~0.69.0", + "@azure-tools/typespec-azure-resource-manager": "~0.69.0", + "@azure-tools/typespec-azure-rulesets": "~0.69.0", + "@azure-tools/typespec-client-generator-core": "~0.69.0", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "~0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/http-specs": "0.1.0-alpha.38-dev.1", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "~0.82.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "~0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "~0.83.0", "@typespec/spec-api": "0.1.0-alpha.14", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "~0.82.0", - "@typespec/streams": "~0.82.0", - "@typespec/versioning": "~0.82.0", - "@typespec/xml": "~0.82.0", + "@typespec/sse": "~0.83.0", + "@typespec/streams": "~0.83.0", + "@typespec/versioning": "~0.83.0", + "@typespec/xml": "~0.83.0", "c8": "^10.1.3", "picocolors": "~1.1.1", "rimraf": "~6.1.2", @@ -49,63 +49,63 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.4 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.42-dev.0", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.42-dev.0.tgz", - "integrity": "sha512-Ps9zmf09b7HbG4WbNc1dymAlTDD2TuXt1l4rfSZOEeyQ0mqUdwZHATRBHboqV5i0XGttILYzd/zLXZsCBC6Kdg==", + "version": "0.1.0-alpha.42", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.42.tgz", + "integrity": "sha512-vQOAepoGK1lSc9ohAub+NM1MiLJS5swIA5Ya3TTIJ4KkD1x6j5msdSRMgNgb0rmux/WWrKTRtsFDAiOF1Z0HKg==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14 || >=0.1.0-alpha.15-dev <0.1.0-alpha.15", - "@typespec/spector": "^0.1.0-alpha.25 || >=0.1.0-alpha.26-dev <0.1.0-alpha.26" + "@typespec/spec-api": "^0.1.0-alpha.14", + "@typespec/spector": "^0.1.0-alpha.25" }, "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0 || >=0.69.0-dev <0.69.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0 || >=0.83.0-dev <0.83.0", - "@typespec/versioning": "^0.82.0 || >=0.83.0-dev <0.83.0", - "@typespec/xml": "^0.82.0 || >=0.83.0-dev <0.83.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.68.0.tgz", - "integrity": "sha512-ywcB68x0jOuplKg1u9ZpjOamHbIEEgAaMuXTP72cvWXE7q1eGLCN1DQx1Uk5ME8VLJKAX6cMOMHK4hcmg9tvuw==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.69.0.tgz", + "integrity": "sha512-6lOOe3NWfLI8M5NGLM1ZzIFRe34gVPj2GXzti9ag6o3fVpC6eMUfacv1sU4zmz9dkpKTdOUXNO5qm3DvqPRC8Q==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/xml": { @@ -114,24 +114,24 @@ } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.68.0.tgz", - "integrity": "sha512-p0qUkRZav5fdQvGe2gSCvlgsvpM0y9xVhgH2GpXi5ZzpYfNGzxd8oZr8VOCP8mjMVfGQ3AtnowbmrHALEZgz7Q==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.69.0.tgz", + "integrity": "sha512-UNdPb/DgMvXqwWk9hb54QOAumCJ6u6GGy+bj3RIIT1Sht6FR9rIn8AQ/UQ7WtrhbJBoqvQo5dxtS565a9/VRZw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.68.0.tgz", - "integrity": "sha512-1zgXpOb/fGfB7SrFqawKasSOTIi9cZPWyK8V3RHyNWFZVQclEMGBzSvBHi6an4AEChqcjCSMh5MEr4BSujW4Ew==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.69.0.tgz", + "integrity": "sha512-q/kdsGhVpvn2wb3OedxFHg7hp+al3FynUAPsz2gwqJx62z6UGOEJhtYCWP3osatVgxvKRhhh8uYl5mHRMDFi3g==", "dev": true, "license": "MIT", "dependencies": { @@ -142,34 +142,34 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-rulesets": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.68.0.tgz", - "integrity": "sha512-cXZ3jiDNqJgpBQLguNgXjvAsvYo7VwtlQxFMzTr96gpoAiuBViH+3eOhVd5HA4H96NgAWSddTMHXZJZzcsnE5A==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.69.0.tgz", + "integrity": "sha512-+7KThtfHupWBDSwDR9rRHNmBb15gxACH8iPOOohRr1J28Gu25YWlz1G00r62X9VUBFLZTxYc4rQ2QCxPFT0uFw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.4", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.4.tgz", - "integrity": "sha512-p32EXsrSC9giZUNdsQ2gmvDENFIEW2E0zto3FmjBZ3OeB5wCw1ZAZ+KnO0rsoKFovBvHSsQatNCKJvM/x89AgA==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.69.0.tgz", + "integrity": "sha512-ro8zzOeiN/74r0wM19R77gzLtbfjIFgKgr1Rusii/vhCfJIoVC7IcqLxhbJl0RVkjyhRFKt4GCRAw4iurnrDnw==", "dev": true, "license": "MIT", "dependencies": { @@ -181,16 +181,16 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/sse": "^0.82.0", - "@typespec/streams": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/sse": "^0.83.0", + "@typespec/streams": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure/abort-controller": { @@ -2384,9 +2384,9 @@ } }, "node_modules/@typespec/compiler": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.12.0.tgz", - "integrity": "sha512-hKCkHEEDdCpXFyOU8ln+TzBBwonFMbkeUV0zIc+vBETyO8p/Upui3XvEyLOyB4CpKUReHzGeGm3gcFjNc73ygg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.13.0.tgz", + "integrity": "sha512-DonoHiyAMx0UjSmssqTrFtya+v97wny1aHcTLU5QF2wFzLATtcwUU9hbPC+eXhepuTunMOCHf8yk3pEsH6PZYA==", "dev": true, "license": "MIT", "dependencies": { @@ -2497,30 +2497,30 @@ } }, "node_modules/@typespec/events": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.82.0.tgz", - "integrity": "sha512-4gxwWndMVmYF6e5ETrwW6b77h1DsSc2ZiIbNo98XePaynD6yz/ooHKKtNKacjC2gmWhfRz1ArPioYn0YHvQkxw==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.83.0.tgz", + "integrity": "sha512-3EP1EIjdLgwStgd2rGWaF/QqY7YRAt+DIYnnYG2VsdPwa8s2t6K6eJ9YJDXveeHImAkHs+cpFuwxnjKMl4hOyw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/http": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.12.0.tgz", - "integrity": "sha512-3Bb1M6VSuEVPWOecXj3h3I/ddMpb9cmKRQQq34oq7LatiK4fwVBp+EdWbqzEzaRUGHm9mZtqsMsxZf5FndT8dg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.13.0.tgz", + "integrity": "sha512-tf8XFddU6g1MZSAVCLC/0Xa4fNfUO0CcHe6PWpmC3bvUojxMnpRcERI2DdoRJ+aycB9Q+Z8wN8bJO3up6u+sCw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/streams": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -2529,52 +2529,52 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.38-dev.1", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38-dev.1.tgz", - "integrity": "sha512-FqvLW1nM5P0WBvA5TTghgrrxPYLPsjFA4fN4V4mKumuBDG4ty3+KjBpJvFZE3GVCIsXQqP+sF08YzC5nG3iV+g==", + "version": "0.1.0-alpha.38", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38.tgz", + "integrity": "sha512-/DlR8P93iFhULlLYDUy+aSkOW2udDrHdIfdIHko8aFnmfC5QGXE2fcFphtNlJHCQEYTdZwfAxmBu/TsEygR8jw==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.0", - "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.0" + "@typespec/spec-api": "^0.1.0-alpha.14", + "@typespec/spector": "^0.1.0-alpha.25" }, "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0 || >= 1.13.0-dev.12", - "@typespec/http": "^1.12.0 || >= 1.13.0-dev.0", - "@typespec/rest": "^0.82.0 || >= 0.83.0-dev.0", - "@typespec/versioning": "^0.82.0 || >= 0.83.0-dev.0", - "@typespec/xml": "^0.82.0 || >= 0.83.0-dev.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@typespec/openapi": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.12.0.tgz", - "integrity": "sha512-XtkCMPpzXFfuIzmx/BQrCMUCCk7d37lkqZe5ubJmvJ02Fr7yvAbofrgtNUZ1BbFe3TBBUS2nB3E3mjT3tE4zCQ==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.13.0.tgz", + "integrity": "sha512-omPc9n+LM2WvjYwnIf31RCxmG17fFUOVLBRsWg4T1mbcsNCj4grnNP7Lwt+irIZCiKtmLKxq3ViE7jYixCkZ3g==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/rest": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.82.0.tgz", - "integrity": "sha512-cKjKEd8lgE3EdU9b5xXLoSdKBcifITOhHS2n9LPbEG9w6APfWDWGdtUe4UKV3wxWq9HlT143wpECW7IjrPhjnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.83.0.tgz", + "integrity": "sha512-WMEwEe1kdaOdZ0c+ct5BVmTSBXkrPniUYDWCz3K52T4in2dNc7J6YGP6tL8bXgQz5B0CsP0VNO12N+UysQDsLw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/spec-api": { @@ -2770,32 +2770,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.82.0.tgz", - "integrity": "sha512-4jBByfLsS7yQAIqmbLkfrw4XoPm9kOqawvW5gVXmKtnMMDYR0RmfBhsnAXBqhUXGbnFq0bDJGEw3GX+6k3mKnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.83.0.tgz", + "integrity": "sha512-04WNaju2rwBbcF5pG+HrKQtdcrmSGuTVziLHNA9XOqj1qM7Uon3+wo2g+ZZ3Z6tngfqQoTCPyDcRHqZtGRdNuw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/streams": "^0.83.0" } }, "node_modules/@typespec/streams": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.82.0.tgz", - "integrity": "sha512-cr/6h6VV/6OJeG8RNcSd0SDes5iEXiuGUcKGrMN6wF8qKTTrY2hXNhfqCCn3lamDOg00wbi7ke+laz6pHWN3tg==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.83.0.tgz", + "integrity": "sha512-wbO6sdH1Uf+UwjxxsWdHQkjJ3wwiYsAKI+L66qnDYVXAFe02sUdMKd0mxH5o9ipGXE52MZ+yvZ52vHAD+g3RFQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -2814,29 +2814,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.82.0.tgz", - "integrity": "sha512-s8giuYQTQPniy2YxNfKXYpAU2Vm4L74TdOsbFWe0tG+jnOy/9tt7kKTH4QF1sB8nRvmjv8h31EoHtZYOPe1GvA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.83.0.tgz", + "integrity": "sha512-nE66ta0ixpHB6FQpSzqnj8QnVfgFsxeK/4Xv+DxYx2nB/w18f6VjkF+hW+A/zs1tZIYvBZVbCNa/Rcr8zM6fhg==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/xml": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.82.0.tgz", - "integrity": "sha512-/Bwlt7HwSltojSbalkh7hGRh/lB5aMJllnb7gAAf3xRPMlnmu5VJqDFFcbZKqDvkwgGXZX/xHo458c4kott5Ug==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.83.0.tgz", + "integrity": "sha512-2/dtAD8jGPkIdwpQ1G1P+5+qdMPeafQiIKCd8NdAnOo0w9OZ59Io52jINm9HdN8+FcbOrqK8+B2N9rlPRj7PqA==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@vitest/expect": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 696ffe46cd2..9d23b841e5a 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-python", - "version": "0.31.0", + "version": "0.31.1", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://typespec.io", @@ -60,20 +60,20 @@ "emitter" ], "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.4 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" }, "playgroundConfig": { "assets": [ @@ -98,24 +98,24 @@ "tsx": "^4.21.0" }, "devDependencies": { - "@azure-tools/typespec-autorest": "~0.68.0", - "@azure-tools/typespec-azure-core": "~0.68.0", - "@azure-tools/typespec-azure-resource-manager": "~0.68.0", - "@azure-tools/typespec-azure-rulesets": "~0.68.0", - "@azure-tools/typespec-client-generator-core": "~0.68.4", - "@azure-tools/azure-http-specs": "0.1.0-alpha.42-dev.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "~0.82.0", - "@typespec/versioning": "~0.82.0", - "@typespec/events": "~0.82.0", + "@azure-tools/typespec-autorest": "~0.69.0", + "@azure-tools/typespec-azure-core": "~0.69.0", + "@azure-tools/typespec-azure-resource-manager": "~0.69.0", + "@azure-tools/typespec-azure-rulesets": "~0.69.0", + "@azure-tools/typespec-client-generator-core": "~0.69.0", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "~0.83.0", + "@typespec/versioning": "~0.83.0", + "@typespec/events": "~0.83.0", "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", - "@typespec/sse": "~0.82.0", - "@typespec/streams": "~0.82.0", - "@typespec/xml": "~0.82.0", - "@typespec/http-specs": "0.1.0-alpha.38-dev.1", + "@typespec/sse": "~0.83.0", + "@typespec/streams": "~0.83.0", + "@typespec/xml": "~0.83.0", + "@typespec/http-specs": "0.1.0-alpha.38", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py index 15b8038fefd..0882c317949 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_commonproperties_async.py @@ -12,6 +12,11 @@ SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" RESOURCE_GROUP_NAME = "test-rg" +SIMPLE_ARM_ID = f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Network/virtualNetworks/myVnet" +ARM_ID_WITH_TYPE = SIMPLE_ARM_ID +ARM_ID_WITH_TYPE_AND_SCOPE = SIMPLE_ARM_ID +ARM_ID_WITH_ALL_SCOPES = f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Compute/virtualMachines/myVm" + @pytest_asyncio.fixture async def client(credential, authentication_policy): @@ -93,3 +98,39 @@ async def test_error_create_for_user_defined_error(client): except exceptions.HttpResponseError as e: assert e.status_code == 400 assert e.error.message == "Username should not contain only numbers." + + +@pytest.mark.asyncio +async def test_arm_resource_identifiers_get(client): + result = await client.arm_resource_identifiers.get( + resource_group_name=RESOURCE_GROUP_NAME, arm_resource_identifier_resource_name="armId" + ) + assert result.location == "eastus" + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.simple_arm_id == SIMPLE_ARM_ID + assert result.properties.arm_id_with_type == ARM_ID_WITH_TYPE + assert result.properties.arm_id_with_type_and_scope == ARM_ID_WITH_TYPE_AND_SCOPE + assert result.properties.arm_id_with_all_scopes == ARM_ID_WITH_ALL_SCOPES + + +@pytest.mark.asyncio +async def test_arm_resource_identifiers_create_or_replace(client): + result = await client.arm_resource_identifiers.create_or_replace( + resource_group_name=RESOURCE_GROUP_NAME, + arm_resource_identifier_resource_name="armId", + resource=models.ArmResourceIdentifierResource( + location="eastus", + properties=models.ArmResourceIdentifierResourceProperties( + simple_arm_id=SIMPLE_ARM_ID, + arm_id_with_type=ARM_ID_WITH_TYPE, + arm_id_with_type_and_scope=ARM_ID_WITH_TYPE_AND_SCOPE, + arm_id_with_all_scopes=ARM_ID_WITH_ALL_SCOPES, + ), + ), + ) + assert result.location == "eastus" + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.simple_arm_id == SIMPLE_ARM_ID + assert result.properties.arm_id_with_type == ARM_ID_WITH_TYPE + assert result.properties.arm_id_with_type_and_scope == ARM_ID_WITH_TYPE_AND_SCOPE + assert result.properties.arm_id_with_all_scopes == ARM_ID_WITH_ALL_SCOPES diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_managementgroup_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_managementgroup_async.py new file mode 100644 index 00000000000..f51c7d9c1e4 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_managementgroup_async.py @@ -0,0 +1,82 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from azure.resourcemanager.managementgroup.aio import ManagementGroupClient +from azure.resourcemanager.managementgroup import models + +MANAGEMENT_GROUP_ID = "test-mg" +RESOURCE_NAME = "resource" + + +@pytest_asyncio.fixture +async def client(credential, authentication_policy): + async with ManagementGroupClient( + credential, "http://localhost:3000", authentication_policy=authentication_policy + ) as client: + yield client + + +@pytest.mark.asyncio +async def test_management_group_child_resources_get(client): + result = await client.management_group_child_resources.get( + management_group_id=MANAGEMENT_GROUP_ID, management_group_child_resource_name=RESOURCE_NAME + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_management_group_child_resources_create_or_update(client): + result = await ( + await client.management_group_child_resources.begin_create_or_update( + management_group_id=MANAGEMENT_GROUP_ID, + management_group_child_resource_name=RESOURCE_NAME, + resource=models.ManagementGroupChildResource( + properties=models.ManagementGroupChildResourceProperties(description="valid") + ), + polling_interval=0, + ) + ).result() + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_management_group_child_resources_update(client): + result = await client.management_group_child_resources.update( + management_group_id=MANAGEMENT_GROUP_ID, + management_group_child_resource_name=RESOURCE_NAME, + properties=models.ManagementGroupChildResource( + properties=models.ManagementGroupChildResourceProperties(description="valid2") + ), + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid2" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_management_group_child_resources_delete(client): + await client.management_group_child_resources.delete( + management_group_id=MANAGEMENT_GROUP_ID, management_group_child_resource_name=RESOURCE_NAME + ) + + +@pytest.mark.asyncio +async def test_management_group_child_resources_list_by_management_group(client): + result = [ + item + async for item in client.management_group_child_resources.list_by_management_group( + management_group_id=MANAGEMENT_GROUP_ID + ) + ] + assert len(result) == 1 + assert result[0].name == RESOURCE_NAME + assert result[0].properties.description == "valid" + assert result[0].properties.provisioning_state == "Succeeded" diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py new file mode 100644 index 00000000000..df3a090325c --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from service.multipleservices.servicea.aio import ServiceAClient +from service.multipleservices.serviceb.aio import ServiceBClient + + +@pytest_asyncio.fixture +async def client_a(): + async with ServiceAClient() as client: + yield client + + +@pytest_asyncio.fixture +async def client_b(): + async with ServiceBClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_service_a_op(client_a: ServiceAClient): + await client_a.operations.op_a() + + +@pytest.mark.asyncio +async def test_service_a_sub_namespace_op(client_a: ServiceAClient): + await client_a.sub_namespace.sub_op_a() + + +@pytest.mark.asyncio +async def test_service_b_op(client_b: ServiceBClient): + await client_b.operations.op_b() + + +@pytest.mark.asyncio +async def test_service_b_sub_namespace_op(client_b: ServiceBClient): + await client_b.sub_namespace.sub_op_b() diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_arm_commonproperties.py b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_commonproperties.py index fab853d096f..3b44eefa869 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_arm_commonproperties.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_commonproperties.py @@ -11,6 +11,11 @@ SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" RESOURCE_GROUP_NAME = "test-rg" +SIMPLE_ARM_ID = f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Network/virtualNetworks/myVnet" +ARM_ID_WITH_TYPE = SIMPLE_ARM_ID +ARM_ID_WITH_TYPE_AND_SCOPE = SIMPLE_ARM_ID +ARM_ID_WITH_ALL_SCOPES = f"/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Compute/virtualMachines/myVm" + @pytest.fixture def client(credential, authentication_policy): @@ -87,3 +92,37 @@ def test_error_create_for_user_defined_error(client): except exceptions.HttpResponseError as e: assert e.status_code == 400 assert e.error.message == "Username should not contain only numbers." + + +def test_arm_resource_identifiers_get(client): + result = client.arm_resource_identifiers.get( + resource_group_name=RESOURCE_GROUP_NAME, arm_resource_identifier_resource_name="armId" + ) + assert result.location == "eastus" + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.simple_arm_id == SIMPLE_ARM_ID + assert result.properties.arm_id_with_type == ARM_ID_WITH_TYPE + assert result.properties.arm_id_with_type_and_scope == ARM_ID_WITH_TYPE_AND_SCOPE + assert result.properties.arm_id_with_all_scopes == ARM_ID_WITH_ALL_SCOPES + + +def test_arm_resource_identifiers_create_or_replace(client): + result = client.arm_resource_identifiers.create_or_replace( + resource_group_name=RESOURCE_GROUP_NAME, + arm_resource_identifier_resource_name="armId", + resource=models.ArmResourceIdentifierResource( + location="eastus", + properties=models.ArmResourceIdentifierResourceProperties( + simple_arm_id=SIMPLE_ARM_ID, + arm_id_with_type=ARM_ID_WITH_TYPE, + arm_id_with_type_and_scope=ARM_ID_WITH_TYPE_AND_SCOPE, + arm_id_with_all_scopes=ARM_ID_WITH_ALL_SCOPES, + ), + ), + ) + assert result.location == "eastus" + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.simple_arm_id == SIMPLE_ARM_ID + assert result.properties.arm_id_with_type == ARM_ID_WITH_TYPE + assert result.properties.arm_id_with_type_and_scope == ARM_ID_WITH_TYPE_AND_SCOPE + assert result.properties.arm_id_with_all_scopes == ARM_ID_WITH_ALL_SCOPES diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_arm_managementgroup.py b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_managementgroup.py new file mode 100644 index 00000000000..3a5bf3b4fa3 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_managementgroup.py @@ -0,0 +1,71 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.managementgroup import ManagementGroupClient +from azure.resourcemanager.managementgroup import models + +MANAGEMENT_GROUP_ID = "test-mg" +RESOURCE_NAME = "resource" + + +@pytest.fixture +def client(credential, authentication_policy): + with ManagementGroupClient( + credential, "http://localhost:3000", authentication_policy=authentication_policy + ) as client: + yield client + + +def test_management_group_child_resources_get(client): + result = client.management_group_child_resources.get( + management_group_id=MANAGEMENT_GROUP_ID, management_group_child_resource_name=RESOURCE_NAME + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +def test_management_group_child_resources_create_or_update(client): + result = client.management_group_child_resources.begin_create_or_update( + management_group_id=MANAGEMENT_GROUP_ID, + management_group_child_resource_name=RESOURCE_NAME, + resource=models.ManagementGroupChildResource( + properties=models.ManagementGroupChildResourceProperties(description="valid") + ), + polling_interval=0, + ).result() + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +def test_management_group_child_resources_update(client): + result = client.management_group_child_resources.update( + management_group_id=MANAGEMENT_GROUP_ID, + management_group_child_resource_name=RESOURCE_NAME, + properties=models.ManagementGroupChildResource( + properties=models.ManagementGroupChildResourceProperties(description="valid2") + ), + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid2" + assert result.properties.provisioning_state == "Succeeded" + + +def test_management_group_child_resources_delete(client): + client.management_group_child_resources.delete( + management_group_id=MANAGEMENT_GROUP_ID, management_group_child_resource_name=RESOURCE_NAME + ) + + +def test_management_group_child_resources_list_by_management_group(client): + result = list( + client.management_group_child_resources.list_by_management_group(management_group_id=MANAGEMENT_GROUP_ID) + ) + assert len(result) == 1 + assert result[0].name == RESOURCE_NAME + assert result[0].properties.description == "valid" + assert result[0].properties.provisioning_state == "Succeeded" diff --git a/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py b/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py new file mode 100644 index 00000000000..1949fba529c --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from service.multipleservices.servicea import ServiceAClient +from service.multipleservices.serviceb import ServiceBClient + + +@pytest.fixture +def client_a(): + with ServiceAClient() as client: + yield client + + +@pytest.fixture +def client_b(): + with ServiceBClient() as client: + yield client + + +def test_service_a_op(client_a: ServiceAClient): + client_a.operations.op_a() + + +def test_service_a_sub_namespace_op(client_a: ServiceAClient): + client_a.sub_namespace.sub_op_a() + + +def test_service_b_op(client_b: ServiceBClient): + client_b.operations.op_b() + + +def test_service_b_sub_namespace_op(client_b: ServiceBClient): + client_b.sub_namespace.sub_op_b() From 9b4f2f7907d8d83504035da7358285c4301c3fcc Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 10 Jun 2026 11:16:09 -0700 Subject: [PATCH 06/29] fix(http-client-csharp): pin cop version and migrate to provider() API (#10954) ## Problem The cop static-analysis runner added in #10909 tracks the `latest` cop release. Upstream cop advanced to **v2026.6.9.1**, which replaced the `code.codebase('csharp')` query API with the global `provider('csharp')` function. `code` is now a provider proxy with no `codebase` method, so the check fails with: ` line 18: Cannot call 'codebase' on CopProviderProxy ` This breaks the `CSharp - Test` CI job on **every** open PR (e.g. #10907), since CI runs cop against each PR merged with `main`. ## Fix - **Pin** the cop release to `v2026.6.9.1` in `Invoke-Cop.ps1` instead of tracking `latest`, so upstream cop releases can no longer break our build. Pinning is safe because the script already vendors provider packages from the cop repo tag reported by `cop -v`, so the providers always match the pinned binary. - **Migrate** `main.cop` from `code.codebase('csharp')` to `let cb : Codebase = provider('csharp')` (the current cop API, matching the cop `code` package samples). Verified locally: `cop checks passed.` Bumping the pin is now a deliberate, reviewable change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../http-client-csharp/cop-checks/main.cop | 2 +- .../eng/scripts/Invoke-Cop.ps1 | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/http-client-csharp/cop-checks/main.cop b/packages/http-client-csharp/cop-checks/main.cop index c7d8f30075e..6bbd028296f 100644 --- a/packages/http-client-csharp/cop-checks/main.cop +++ b/packages/http-client-csharp/cop-checks/main.cop @@ -15,7 +15,7 @@ import code import csharp -let cb = code.codebase('csharp') +let cb : Codebase = provider('csharp') # Rule: braces.cop command CHECK-BRACES = foreach cb.Lines:missingBraces => '{error:@red} {item.File.Path}:{item.Number}: missing braces -> {item.Text}' diff --git a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 index ae33b0fba0e..d9b7bb768d9 100644 --- a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 +++ b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 @@ -16,20 +16,29 @@ the rule files. This keeps cop targeted at the generator (via -t) and avoids scanning node_modules or the rest of the repository. .PARAMETER Version -The cop release tag to use, or "latest" (default) to track the newest release. - -NOTE: cop auto-restores its provider packages (code, csharp) from the GitHub -feed, and the feed always serves the *latest* provider build. Those providers -are version-locked to the cop runtime assembly, so the binary must match the -provider version the feed currently serves -- otherwise the provider fails to -load ("Could not load file or assembly 'cop, Version=...'"). Because the feed -moves with upstream, we default to "latest" so the binary stays in lockstep with -the providers. Pass an explicit tag only to reproduce a historical run. +The cop release tag to use. Defaults to a pinned tag so CI is reproducible and +upstream cop releases cannot break our build. + +NOTE: cop's provider packages (code, csharp) are version-locked to the cop +runtime assembly -- a mismatch makes the provider fail to load ("Could not load +file or assembly 'cop, Version=...'"). We do NOT rely on cop's auto-restore feed +(which always serves the *latest* provider build); instead we vendor the +provider packages from the cop repo at the tag reported by `cop -v` (see below), +so they always match the downloaded binary. Because of that, pinning the binary +to a fixed tag is safe: the providers are pinned to the same tag automatically. + +Bumping the pinned version is a deliberate, reviewable change. Before bumping, +verify the rule files in cop-checks/ still run against the new release, since +cop occasionally makes breaking changes to its query API between releases. +Pass "latest" to test against the newest release. #> [CmdletBinding()] param( - [string] $Version = "latest" + # Pinned cop release. Bump deliberately after verifying the cop-checks/ rules + # still run against the new release (cop can make breaking API changes + # between releases). Pass "latest" to test against the newest release. + [string] $Version = "v2026.6.9.1" ) $ErrorActionPreference = 'Stop' @@ -71,9 +80,9 @@ else { $url = "https://github.com/KrzysztofCwalina/cop/releases/download/$Version/$asset" } -# Cache the downloaded tool per version + platform. When tracking "latest" the -# tag is not fixed, so always re-download to stay in lockstep with the feed's -# provider packages. +# Cache the downloaded tool per version + platform. A pinned tag is immutable, so +# a cached copy can be reused; when "latest" is requested the tag is not fixed, so +# always re-download to stay in lockstep with the feed's provider packages. $toolDir = Join-Path ([System.IO.Path]::GetTempPath()) "cop-$Version-$os-$arch" $copPath = Join-Path $toolDir $exe From 26230596940556592aedfde33a2415a13fccac52 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 19:49:36 +0000 Subject: [PATCH 07/29] Add docs on authoring and using generator plugins for the C# emitter (#10907) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `plugins` emitter option (added in #10249) lets emitter authors load custom generator plugins, but there was no documentation describing how to author or use them. This adds a guide to the existing `packages/http-client-csharp/docs`. ## Changes - **New `docs/plugins.md`** covering: - Plugin discovery: automatic (via `node_modules` `dist`) vs. explicit (via the `plugins` option). - Authoring a `GeneratorPlugin` subclass and the `CodeModelGenerator` extension points (`AddVisitor`, `AddRewriter`, `AddMetadataReference`, `AddSharedSourceDirectory`), plus a `LibraryVisitor` example. - A minimal plugin `.csproj` that references the generator via a NuGet `PackageReference` to the published `Microsoft.TypeSpec.Generator.ClientModel` package (which transitively brings in `Microsoft.TypeSpec.Generator`). - `tspconfig.yaml` usage and path-resolution behavior (paths absolute or relative to the resolved `emitter-output-dir`, auto-build of `.csproj`, DLL scanning). - **`emitter.md`** — `plugins` option now links to the new guide and includes the inline path-resolution example. - **`index.mdx`** — adds a "Generator plugins" section linking to the doc. - **`emitter/src/options.ts`** — expanded the `plugins` option description to document path resolution (absolute or relative to the resolved `emitter-output-dir`) with an inline YAML example, applying the inline examples from #10908. - **`readme.md`** and website reference `emitter.md` — regenerated to reflect the updated option description. Plugin authoring example: ```csharp using Microsoft.TypeSpec.Generator; public class MyPlugin : GeneratorPlugin { public override void Apply(CodeModelGenerator generator) { generator.AddVisitor(new MyLibraryVisitor()); } } ``` ```yaml options: "@typespec/http-client-csharp": plugins: - "codegen/MyPlugin.dll" # file relative to emitter-output-dir - "codegen" # directory containing plugin assemblies - "/abs/path/to/MyPlugin.dll" # absolute path used as-is ``` Content was cross-checked against `GeneratorPlugin.cs`, `GeneratorHandler.cs`, `CodeModelGenerator.cs`, and the emitter `options.ts`/`emitter.ts`. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: JonathanCrd <17486462+JonathanCrd@users.noreply.github.com> Co-authored-by: jolov --- packages/http-client-csharp/docs/emitter.md | 13 ++- packages/http-client-csharp/docs/index.mdx | 4 + packages/http-client-csharp/docs/plugins.md | 101 ++++++++++++++++++ .../http-client-csharp/emitter/src/options.ts | 12 ++- packages/http-client-csharp/readme.md | 11 +- .../http-client-csharp/reference/emitter.md | 11 +- 6 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 packages/http-client-csharp/docs/plugins.md diff --git a/packages/http-client-csharp/docs/emitter.md b/packages/http-client-csharp/docs/emitter.md index f20d6edee33..1f968bcce9f 100644 --- a/packages/http-client-csharp/docs/emitter.md +++ b/packages/http-client-csharp/docs/emitter.md @@ -112,7 +112,18 @@ Allows emitter authors to specify the path to a custom emitter package, allowing **Type:** `array` -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` + +See [Generator plugins](./plugins.md) for a walkthrough on authoring and using plugins. ### `license` diff --git a/packages/http-client-csharp/docs/index.mdx b/packages/http-client-csharp/docs/index.mdx index ca373e97796..d2cbde176f7 100644 --- a/packages/http-client-csharp/docs/index.mdx +++ b/packages/http-client-csharp/docs/index.mdx @@ -32,6 +32,10 @@ npm install --save-peer @typespec/http-client-csharp [See documentation](./emitter.md) +## Generator plugins + +[See documentation](./plugins.md) + ## TypeSpec.HttpClient ## TypeSpec.HttpClient.CSharp diff --git a/packages/http-client-csharp/docs/plugins.md b/packages/http-client-csharp/docs/plugins.md new file mode 100644 index 00000000000..66834b76ef9 --- /dev/null +++ b/packages/http-client-csharp/docs/plugins.md @@ -0,0 +1,101 @@ +--- +title: "Generator plugins" +--- + +## Generator plugins + +Plugins are a lightweight way to customize the C# generator without authoring a full custom generator. A plugin can register additional visitors, rewriters, metadata references, or shared source directories that participate in the normal generation pipeline. This is useful when you want to tweak the generated output (for example, rename types, add attributes, or post-process models) while still using the built-in `ScmCodeModelGenerator`. + +The generator discovers plugins in two ways: + +1. **Automatically**, from the `dist` folder of any package listed in your project's `node_modules`. +2. **Explicitly**, from the paths supplied via the [`plugins`](./emitter.md#plugins) emitter option. + +This document focuses on the `plugins` option, which lets emitter authors point the generator at one or more plugin assemblies (or directories/projects containing them). + +## Authoring a plugin + +A plugin is a C# class that extends `GeneratorPlugin` and overrides `Apply`. The base class is exported via [MEF](https://learn.microsoft.com/dotnet/framework/mef/) using `[InheritedExport]`, so any subclass is discovered automatically once its assembly is loaded — you do not need to add an `[Export]` attribute yourself. + +```csharp +using Microsoft.TypeSpec.Generator; + +public class MyPlugin : GeneratorPlugin +{ + public override void Apply(CodeModelGenerator generator) + { + // Register a custom visitor that transforms the output library. + generator.AddVisitor(new MyLibraryVisitor()); + } +} +``` + +The `CodeModelGenerator` passed to `Apply` exposes the extension points a plugin can use, including: + +- `AddVisitor(LibraryVisitor visitor)` — add a visitor that traverses and modifies the output library. +- `AddRewriter(LibraryRewriter rewriter)` — add a rewriter to transform generated members. +- `AddMetadataReference(MetadataReference reference)` — make additional assemblies available to the generated code. +- `AddSharedSourceDirectory(string sharedSourceDirectory)` — include a directory of shared source files. + +A visitor lets you hook into specific parts of the output. For example, to transform every model: + +```csharp +using Microsoft.TypeSpec.Generator; +using Microsoft.TypeSpec.Generator.Providers; + +public class MyLibraryVisitor : LibraryVisitor +{ + protected override TypeProvider? VisitType(TypeProvider type) + { + // Inspect or modify the generated type here. + return base.VisitType(type); + } +} +``` + +### Plugin project file + +Build your plugin as a class library that references the generator's published NuGet package. Referencing `Microsoft.TypeSpec.Generator.ClientModel` transitively brings in `Microsoft.TypeSpec.Generator`, which contains the `GeneratorPlugin` base class. Use the package version that matches the version of `@typespec/http-client-csharp` you are generating with. A minimal `.csproj` looks like this: + +```xml + + + + net10.0 + enable + + + + + + + +``` + +## Using the `plugins` option + +Once you have a plugin, point the emitter at it using the `plugins` option in `tspconfig.yaml`. Each entry is a path that may be **absolute** or **relative to the resolved `emitter-output-dir`**. A path can point to either: + +- a **file** — a pre-built plugin assembly (`*.dll`), or +- a **directory** containing pre-built plugin assemblies (`*.dll`) or a `.csproj` — when a `.csproj` is present the generator builds it (`dotnet build -c Release`) before loading the resulting assembly. + +For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +emit: + - "@typespec/http-client-csharp" +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` + +Notes: + +- Absolute paths are used as-is; relative paths are anchored to the resolved `emitter-output-dir`. +- When a directory contains a `.csproj`, it is built automatically; otherwise the directory is scanned for pre-built `*.dll` files. +- Plugins loaded via the `plugins` option are applied in addition to any plugins discovered through `node_modules`. + +After the assemblies are loaded, every discovered `GeneratorPlugin` has its `Apply` method invoked on the selected generator before generation runs, so all of your registered visitors, rewriters, and references take effect. diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index b980b4121f8..9b9529c9ce2 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -120,7 +120,17 @@ export const CSharpEmitterOptionsSchema: JSONSchemaType = nullable: true, description: "Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. " + - "Each plugin must contain a class that extends GeneratorPlugin.", + "Each plugin must contain a class that extends `GeneratorPlugin`. " + + "Paths may be absolute or relative to the resolved `emitter-output-dir`. " + + "For example, to load plugins that live in a `codegen` folder under the output directory:\n\n" + + "```yaml\n" + + "options:\n" + + ' "@typespec/http-client-csharp":\n' + + " plugins:\n" + + ' - "codegen/MyPlugin.dll" # file relative to emitter-output-dir\n' + + ' - "codegen" # directory containing plugin assemblies\n' + + ' - "/abs/path/to/MyPlugin.dll" # absolute path used as-is\n' + + "```", }, license: { type: "object", diff --git a/packages/http-client-csharp/readme.md b/packages/http-client-csharp/readme.md index 2acc3d7cbaf..beb26cda25e 100644 --- a/packages/http-client-csharp/readme.md +++ b/packages/http-client-csharp/readme.md @@ -129,7 +129,16 @@ Allows emitter authors to specify the path to a custom emitter package, allowing **Type:** `array` -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` ### `license` diff --git a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md index f20d6edee33..10b52769c33 100644 --- a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md +++ b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md @@ -112,7 +112,16 @@ Allows emitter authors to specify the path to a custom emitter package, allowing **Type:** `array` -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: + +```yaml +options: + "@typespec/http-client-csharp": + plugins: + - "codegen/MyPlugin.dll" # file relative to emitter-output-dir + - "codegen" # directory containing plugin assemblies + - "/abs/path/to/MyPlugin.dll" # absolute path used as-is +``` ### `license` From 3cb92221f79db70b44534acd075407926d5ad087 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 20:36:48 +0000 Subject: [PATCH 08/29] Bump TCGC to 0.69.0 for http-client-csharp (#10952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps `@azure-tools/typespec-client-generator-core` to 0.69.0 and its related dependencies for the `http-client-csharp` package, and regenerates the test projects. ### Dependency bumps (`package.json`) - `@azure-tools/typespec-client-generator-core`: `0.68.3` → `0.69.0` - `@azure-tools/typespec-azure-core`: `0.68.0` → `0.69.0` - `@azure-tools/azure-http-specs`: `0.1.0-alpha.40` → `0.1.0-alpha.42` - `@typespec/compiler`, `@typespec/http`, `@typespec/openapi`, `@typespec/json-schema`: `1.12.0` → `1.13.0` - `@typespec/rest`, `@typespec/sse`, `@typespec/streams`, `@typespec/versioning`, `@typespec/xml`, `@typespec/library-linter`: `0.82.0` → `0.83.0` - `@typespec/http-specs`: `0.1.0-alpha.37` → `0.1.0-alpha.38` - `@typespec/tspd`: `0.74.2` → `0.75.0` - `peerDependencies` ranges shifted up one minor accordingly (e.g. azure-core/TCGC → `>=0.69.0 <0.70.0 || ~0.70.0-0`) The TypeSpec `1.13.0`/`0.83.0` line is required transitively: TCGC 0.69.0 peers on `typespec-azure-core ^0.69.0`, which peers on `@typespec/compiler ^1.13.0`. ### Regenerated output (`Generate.ps1`) Generated changes reflect new spec scenarios introduced by the bumped http-specs packages: - New `parameters/body-root` spec project - New `SpecialChar` sub-client under `parameters/query` - New `Fish` base-discriminator models under `type/model/inheritance/single-discriminator` - Refreshed `launchSettings.json` ### Regenerated tspd docs (`regen-docs`) Because the `@typespec/tspd` bump to `0.75.0` changed the reference-doc output, the docs were regenerated to match (this was the source of the generated-doc diffs flagged in CI): - `packages/http-client-csharp/readme.md` and `website/.../reference/emitter.md`: richer emitter-option type rendering (`plugins` → `string[]`, `license` → object shape plus a properties table) - `website/.../reference/index.mdx`: removed an empty `## TypeSpec.HttpClient` namespace section A clean re-run of `Generate.ps1` confirmed the C# generated test-project code has no remaining diffs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../src/Properties/launchSettings.json | 5 + .../parameters/body-root/Configuration.json | 3 + .../Parameters.BodyRoot.NuGet.targets | 6 + .../body-root/Parameters.BodyRoot.slnx | 3 + .../body-root/src/Generated/BodyRootClient.cs | 35 ++ .../src/Generated/BodyRootClientOptions.cs | 18 + .../src/Generated/BodyRootClientSettings.cs | 29 + .../Models/BodyRootModel.Serialization.cs | 34 ++ .../src/Generated/Models/BodyRootModel.cs | 29 + .../NestedParameterBody.Serialization.cs | 33 ++ .../Generated/Models/NestedParameterBody.cs | 13 + .../Models/ParametersBodyRootContext.cs | 14 + .../ParametersBodyRootModelFactory.cs | 13 + .../Generated/schema/ConfigurationSchema.json | 40 ++ .../body-root/src/Parameters.BodyRoot.csproj | 20 + .../parameters/body-root/tspCodeModel.json | 355 ++++++++++++ .../query/src/Generated/QueryClient.cs | 2 + .../query/src/Generated/SpecialChar.cs | 29 + .../http/parameters/query/tspCodeModel.json | 142 +++++ .../Generated/Models/Fish.Serialization.cs | 39 ++ .../src/Generated/Models/Fish.cs | 28 + .../Models/UnknownFish.Serialization.cs | 33 ++ .../src/Generated/Models/UnknownFish.cs | 14 + ...elInheritanceSingleDiscriminatorContext.cs | 2 + .../Generated/SingleDiscriminatorClient.cs | 16 + ...eritanceSingleDiscriminatorModelFactory.cs | 2 + .../single-discriminator/tspCodeModel.json | 540 ++++++++++++++---- packages/http-client-csharp/package-lock.json | 226 ++++---- packages/http-client-csharp/package.json | 48 +- packages/http-client-csharp/readme.md | 14 +- .../http-client-csharp/reference/emitter.md | 14 +- .../http-client-csharp/reference/index.mdx | 2 - 32 files changed, 1558 insertions(+), 243 deletions(-) create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json index 49a7be36212..695ba6fdd2a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json @@ -85,6 +85,11 @@ "commandName": "Executable", "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe" }, + "http-parameters-body-root": { + "commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/parameters/body-root -g StubLibraryGenerator", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe" + }, "http-parameters-collection-format": { "commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/parameters/collection-format -g StubLibraryGenerator", "commandName": "Executable", diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json new file mode 100644 index 00000000000..ae9cd5f165f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Configuration.json @@ -0,0 +1,3 @@ +{ + "package-name": "Parameters.BodyRoot" +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets new file mode 100644 index 00000000000..9df53f09f6f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.NuGet.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx new file mode 100644 index 00000000000..ce8d57436e8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/Parameters.BodyRoot.slnx @@ -0,0 +1,3 @@ + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs new file mode 100644 index 00000000000..d78b3acea38 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClient.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using System.Threading; +using System.Threading.Tasks; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootClient + { + public BodyRootClient() : this(new Uri("http://localhost:3000"), new BodyRootClientOptions()) => throw null; + + internal BodyRootClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, BodyRootClientOptions options) => throw null; + + public BodyRootClient(Uri endpoint, BodyRootClientOptions options) : this(null, endpoint, options) => throw null; + + [Experimental("SCME0002")] + public BodyRootClient(BodyRootClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Nested(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task NestedAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Nested(NestedParameterBody body, CancellationToken cancellationToken = default) => throw null; + + public virtual Task NestedAsync(NestedParameterBody body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs new file mode 100644 index 00000000000..ef48984732a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientOptions.cs @@ -0,0 +1,18 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootClientOptions : ClientPipelineOptions + { + public BodyRootClientOptions() => throw null; + + [Experimental("SCME0002")] + internal BodyRootClientOptions(IConfigurationSection section) : base(section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs new file mode 100644 index 00000000000..109b1047c05 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/BodyRootClientSettings.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace Parameters.BodyRoot +{ + [Experimental("SCME0002")] + public partial class BodyRootClientSettings : ClientSettings + { + public Uri Endpoint + { + get => throw null; + set => throw null; + } + + public BodyRootClientOptions Options + { + get => throw null; + set => throw null; + } + + protected override void BindCore(IConfigurationSection section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs new file mode 100644 index 00000000000..d78494b73cd --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.Serialization.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Parameters.BodyRoot +{ + public partial class BodyRootModel : IJsonModel + { + protected virtual BodyRootModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + BodyRootModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(BodyRootModel bodyRootModel) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + BodyRootModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual BodyRootModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs new file mode 100644 index 00000000000..2dff18065c2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/BodyRootModel.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public partial class BodyRootModel + { + public BodyRootModel() => throw null; + + public string Category + { + get => throw null; + set => throw null; + } + + public string LinkType + { + get => throw null; + set => throw null; + } + + public bool? WasSuccessful + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs new file mode 100644 index 00000000000..4a61cca774d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Parameters.BodyRoot +{ + public partial class NestedParameterBody : IJsonModel + { + internal NestedParameterBody() => throw null; + + protected virtual NestedParameterBody PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + NestedParameterBody IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + NestedParameterBody IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual NestedParameterBody JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs new file mode 100644 index 00000000000..3598264b2a5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/NestedParameterBody.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public partial class NestedParameterBody + { + public NestedParameterBody(BodyRootModel bodyRootParameters) => throw null; + + public BodyRootModel BodyRootParameters => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs new file mode 100644 index 00000000000..baef5ec78fe --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/Models/ParametersBodyRootContext.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Parameters.BodyRoot +{ + [ModelReaderWriterBuildable(typeof(BodyRootModel))] + [ModelReaderWriterBuildable(typeof(NestedParameterBody))] + public partial class ParametersBodyRootContext : ModelReaderWriterContext + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs new file mode 100644 index 00000000000..347b2cb24c8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/ParametersBodyRootModelFactory.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +namespace Parameters.BodyRoot +{ + public static partial class ParametersBodyRootModelFactory + { + public static BodyRootModel BodyRootModel(string category = default, string linkType = default, bool? wasSuccessful = default) => throw null; + + public static NestedParameterBody NestedParameterBody(BodyRootModel bodyRootParameters = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json new file mode 100644 index 00000000000..9b632a36555 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Generated/schema/ConfigurationSchema.json @@ -0,0 +1,40 @@ +{ + "type": "object", + "properties": { + "Clients": { + "type": "object", + "properties": { + "BodyRootClient": { + "type": "object", + "description": "Configuration for BodyRootClient.", + "properties": { + "Endpoint": { + "type": "string", + "format": "uri", + "description": "Gets or sets the Endpoint." + }, + "Credential": { + "$ref": "#/definitions/credential" + }, + "Options": { + "$ref": "#/definitions/bodyRootClientOptions" + } + } + } + }, + "additionalProperties": { + "type": "object", + "description": "Configuration for a named client instance." + } + } + }, + "definitions": { + "bodyRootClientOptions": { + "allOf": [ + { + "$ref": "#/definitions/options" + } + ] + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj new file mode 100644 index 00000000000..dc8fb18480d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/src/Parameters.BodyRoot.csproj @@ -0,0 +1,20 @@ + + + This is the Parameters.BodyRoot client library for developing .NET applications with rich experience. + SDK Code Generation Parameters.BodyRoot + 1.0.0-beta.1 + Parameters.BodyRoot + netstandard2.0;net8.0 + latest + true + + + + + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json new file mode 100644 index 00000000000..74560ddc5f0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/body-root/tspCodeModel.json @@ -0,0 +1,355 @@ +{ + "name": "Parameters.BodyRoot", + "apiVersions": [], + "enums": [], + "constants": [ + { + "$id": "1", + "kind": "constant", + "name": "NestedContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false + } + ], + "models": [ + { + "$id": "3", + "kind": "model", + "name": "BodyRootModel", + "namespace": "Parameters.BodyRoot", + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel", + "usage": "Input,Json", + "decorators": [], + "serializationOptions": { + "json": { + "name": "BodyRootModel" + } + }, + "isExactName": false, + "properties": [ + { + "$id": "4", + "kind": "property", + "name": "category", + "serializedName": "category", + "type": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.category", + "serializationOptions": { + "json": { + "name": "category" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + { + "$id": "6", + "kind": "property", + "name": "linkType", + "serializedName": "linkType", + "type": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.linkType", + "serializationOptions": { + "json": { + "name": "linkType" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + { + "$id": "8", + "kind": "property", + "name": "wasSuccessful", + "serializedName": "wasSuccessful", + "type": { + "$id": "9", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.BodyRootModel.wasSuccessful", + "serializationOptions": { + "json": { + "name": "wasSuccessful" + } + }, + "isHttpMetadata": false, + "isExactName": false + } + ] + }, + { + "$id": "10", + "kind": "model", + "name": "NestedParameterBody", + "namespace": "Parameters.BodyRoot", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous", + "usage": "Input", + "decorators": [], + "serializationOptions": {}, + "isExactName": false, + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "serializationOptions": {}, + "isHttpMetadata": false, + "isExactName": false + } + ] + } + ], + "clients": [ + { + "$id": "12", + "kind": "client", + "name": "BodyRootClient", + "isExactName": false, + "namespace": "Parameters.BodyRoot", + "doc": "Test for @bodyRoot parameter patterns.", + "methods": [ + { + "$id": "13", + "kind": "basic", + "name": "nested", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "14", + "name": "nested", + "isExactName": false, + "resourceName": "BodyRoot", + "accessibility": "public", + "parameters": [ + { + "$id": "15", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "1" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.contentType", + "methodParameterSegments": [ + { + "$id": "16", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "1" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.contentType", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + }, + { + "$id": "17", + "kind": "body", + "name": "bodyRootParameters", + "serializedName": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "methodParameterSegments": [ + { + "$id": "18", + "kind": "method", + "name": "body", + "serializedName": "body", + "type": { + "$ref": "10" + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.body", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + }, + { + "$id": "19", + "kind": "method", + "name": "bodyRootParameters", + "serializedName": "bodyRootParameters", + "type": { + "$ref": "3" + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested.Parameter.body.anonymous.bodyRootParameters", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false, + "serializationOptions": { + "json": { + "name": "bodyRootParameters" + } + } + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/parameters/body-root/nested", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested", + "decorators": [], + "namespace": "Parameters.BodyRoot" + }, + "parameters": [ + { + "$ref": "18" + }, + { + "$ref": "16" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Parameters.BodyRoot.nested" + } + ], + "parameters": [ + { + "$id": "20", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "21", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.BodyRoot.endpoint", + "isExactName": false + } + ], + "initializedBy": 1, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.BodyRoot", + "apiVersions": [], + "isMultiServiceClient": false + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs index 6a4be8cbeed..862d4747af9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/QueryClient.cs @@ -22,5 +22,7 @@ public partial class QueryClient public ClientPipeline Pipeline => throw null; public virtual Constant GetConstantClient() => throw null; + + public virtual SpecialChar GetSpecialCharClient() => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs new file mode 100644 index 00000000000..02f488d8034 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/src/Generated/SpecialChar.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Parameters.Query +{ + public partial class SpecialChar + { + protected SpecialChar() => throw null; + + internal SpecialChar(ClientPipeline pipeline, Uri endpoint) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult DollarSign(string filter, RequestOptions options) => throw null; + + public virtual Task DollarSignAsync(string filter, RequestOptions options) => throw null; + + public virtual ClientResult DollarSign(string filter, CancellationToken cancellationToken = default) => throw null; + + public virtual Task DollarSignAsync(string filter, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json index 188b51262ae..93d44df48b3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/query/tspCodeModel.json @@ -221,6 +221,148 @@ "$ref": "5" }, "isMultiServiceClient": false + }, + { + "$id": "17", + "kind": "client", + "name": "SpecialChar", + "isExactName": false, + "namespace": "Parameters.Query", + "doc": "Special char query parameter verification", + "methods": [ + { + "$id": "18", + "kind": "basic", + "name": "dollarSign", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "19", + "name": "dollarSign", + "isExactName": false, + "resourceName": "SpecialChar", + "accessibility": "public", + "parameters": [ + { + "$id": "20", + "kind": "query", + "name": "filter", + "serializedName": "$filter", + "type": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "optional": false, + "scope": "Method", + "decorators": [], + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign.filter", + "readOnly": false, + "methodParameterSegments": [ + { + "$id": "22", + "kind": "method", + "name": "filter", + "serializedName": "$filter", + "type": { + "$id": "23", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign.filter", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/parameters/query/special-char/dollarSign", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign", + "decorators": [], + "namespace": "Parameters.Query" + }, + "parameters": [ + { + "$ref": "22" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.dollarSign" + } + ], + "parameters": [ + { + "$id": "24", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "25", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar.endpoint", + "isExactName": false + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Parameters.Query.SpecialChar", + "apiVersions": [], + "parent": { + "$ref": "5" + }, + "isMultiServiceClient": false } ], "isMultiServiceClient": false diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs new file mode 100644 index 00000000000..7ed655a1c0e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.Serialization.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [PersistableModelProxy(typeof(UnknownFish))] + public abstract partial class Fish : IJsonModel + { + internal Fish() => throw null; + + protected virtual Fish PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Fish IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(Fish fish) => throw null; + + public static explicit operator Fish(ClientResult result) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Fish IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual Fish JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs new file mode 100644 index 00000000000..26a9bca69ca --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Fish.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public abstract partial class Fish + { + private protected Fish(string kind, int size) => throw null; + + internal Fish(string kind, int size, IDictionary additionalBinaryDataProperties) => throw null; + + internal string Kind + { + get => throw null; + set => throw null; + } + + public int Size + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs new file mode 100644 index 00000000000..0f803642de8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownFish : Fish, IJsonModel + { + internal UnknownFish() => throw null; + + protected override Fish PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Fish IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Fish IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Fish JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs new file mode 100644 index 00000000000..b2b66b486c0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownFish.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownFish : Fish + { + internal UnknownFish(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", size, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs index 66003f92303..be4653744b5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs @@ -9,12 +9,14 @@ namespace _Type.Model.Inheritance.SingleDiscriminator [ModelReaderWriterBuildable(typeof(Bird))] [ModelReaderWriterBuildable(typeof(Dinosaur))] [ModelReaderWriterBuildable(typeof(Eagle))] + [ModelReaderWriterBuildable(typeof(Fish))] [ModelReaderWriterBuildable(typeof(Goose))] [ModelReaderWriterBuildable(typeof(SeaGull))] [ModelReaderWriterBuildable(typeof(Sparrow))] [ModelReaderWriterBuildable(typeof(TRex))] [ModelReaderWriterBuildable(typeof(UnknownBird))] [ModelReaderWriterBuildable(typeof(UnknownDinosaur))] + [ModelReaderWriterBuildable(typeof(UnknownFish))] public partial class _TypeModelInheritanceSingleDiscriminatorContext : ModelReaderWriterContext { } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs index d6a1a0eb170..e3ad8523343 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs @@ -79,5 +79,21 @@ public partial class SingleDiscriminatorClient public virtual ClientResult GetLegacyModel(CancellationToken cancellationToken = default) => throw null; public virtual Task> GetLegacyModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetNoSubtypesModel(RequestOptions options) => throw null; + + public virtual Task GetNoSubtypesModelAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetNoSubtypesModel(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetNoSubtypesModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult PutNoSubtypesModel(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task PutNoSubtypesModelAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult PutNoSubtypesModel(Fish input, CancellationToken cancellationToken = default) => throw null; + + public virtual Task PutNoSubtypesModelAsync(Fish input, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs index a76389a6425..733864f2b9e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs @@ -21,5 +21,7 @@ public static partial class TypeModelInheritanceSingleDiscriminatorModelFactory public static Dinosaur Dinosaur(string kind = default, int size = default) => throw null; public static TRex TRex(int size = default) => throw null; + + public static Fish Fish(string kind = default, int size = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json index ad84c330c65..380d9194562 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/tspCodeModel.json @@ -206,11 +206,45 @@ "value": "application/json", "decorators": [], "isExactName": false + }, + { + "$id": "25", + "kind": "constant", + "name": "GetModelAccept7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false + }, + { + "$id": "27", + "kind": "constant", + "name": "GetModelAccept8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [], + "isExactName": false } ], "models": [ { - "$id": "25", + "$id": "29", "kind": "model", "name": "Bird", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -225,12 +259,12 @@ }, "isExactName": false, "discriminatorProperty": { - "$id": "26", + "$id": "30", "kind": "property", "name": "kind", "serializedName": "kind", "type": { - "$id": "27", + "$id": "31", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -252,15 +286,15 @@ }, "properties": [ { - "$ref": "26" + "$ref": "30" }, { - "$id": "28", + "$id": "32", "kind": "property", "name": "wingspan", "serializedName": "wingspan", "type": { - "$id": "29", + "$id": "33", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -283,7 +317,7 @@ ], "discriminatedSubtypes": { "seagull": { - "$id": "30", + "$id": "34", "kind": "model", "name": "SeaGull", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -299,11 +333,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "31", + "$id": "35", "kind": "property", "name": "kind", "serializedName": "kind", @@ -327,7 +361,7 @@ ] }, "sparrow": { - "$id": "32", + "$id": "36", "kind": "model", "name": "Sparrow", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -343,11 +377,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "33", + "$id": "37", "kind": "property", "name": "kind", "serializedName": "kind", @@ -371,7 +405,7 @@ ] }, "goose": { - "$id": "34", + "$id": "38", "kind": "model", "name": "Goose", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -387,11 +421,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "35", + "$id": "39", "kind": "property", "name": "kind", "serializedName": "kind", @@ -415,7 +449,7 @@ ] }, "eagle": { - "$id": "36", + "$id": "40", "kind": "model", "name": "Eagle", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -431,11 +465,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "25" + "$ref": "29" }, "properties": [ { - "$id": "37", + "$id": "41", "kind": "property", "name": "kind", "serializedName": "kind", @@ -457,16 +491,16 @@ "isExactName": false }, { - "$id": "38", + "$id": "42", "kind": "property", "name": "friends", "serializedName": "friends", "type": { - "$id": "39", + "$id": "43", "kind": "array", "name": "ArrayBird", "valueType": { - "$ref": "25" + "$ref": "29" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -486,22 +520,22 @@ "isExactName": false }, { - "$id": "40", + "$id": "44", "kind": "property", "name": "hate", "serializedName": "hate", "type": { - "$id": "41", + "$id": "45", "kind": "dict", "keyType": { - "$id": "42", + "$id": "46", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$ref": "25" + "$ref": "29" }, "decorators": [] }, @@ -520,12 +554,12 @@ "isExactName": false }, { - "$id": "43", + "$id": "47", "kind": "property", "name": "partner", "serializedName": "partner", "type": { - "$ref": "25" + "$ref": "29" }, "optional": true, "readOnly": false, @@ -546,19 +580,19 @@ } }, { - "$ref": "30" + "$ref": "34" }, { - "$ref": "32" + "$ref": "36" }, { - "$ref": "34" + "$ref": "38" }, { - "$ref": "36" + "$ref": "40" }, { - "$id": "44", + "$id": "48", "kind": "model", "name": "Dinosaur", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -573,13 +607,13 @@ }, "isExactName": false, "discriminatorProperty": { - "$id": "45", + "$id": "49", "kind": "property", "name": "kind", "serializedName": "kind", "doc": "Discriminator property for Dinosaur.", "type": { - "$id": "46", + "$id": "50", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -601,15 +635,15 @@ }, "properties": [ { - "$ref": "45" + "$ref": "49" }, { - "$id": "47", + "$id": "51", "kind": "property", "name": "size", "serializedName": "size", "type": { - "$id": "48", + "$id": "52", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -632,7 +666,7 @@ ], "discriminatedSubtypes": { "t-rex": { - "$id": "49", + "$id": "53", "kind": "model", "name": "TRex", "namespace": "Type.Model.Inheritance.SingleDiscriminator", @@ -648,11 +682,11 @@ }, "isExactName": false, "baseModel": { - "$ref": "44" + "$ref": "48" }, "properties": [ { - "$id": "50", + "$id": "54", "kind": "property", "name": "kind", "serializedName": "kind", @@ -678,12 +712,85 @@ } }, { - "$ref": "49" + "$ref": "53" + }, + { + "$id": "55", + "kind": "model", + "name": "Fish", + "namespace": "Type.Model.Inheritance.SingleDiscriminator", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish", + "usage": "Input,Output,Json", + "doc": "A discriminated model with no defined subtypes. The discriminator is declared but no models extend it.", + "decorators": [], + "serializationOptions": { + "json": { + "name": "Fish" + } + }, + "isExactName": false, + "discriminatorProperty": { + "$id": "56", + "kind": "property", + "name": "kind", + "serializedName": "kind", + "type": { + "$id": "57", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": true, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish.kind", + "serializationOptions": { + "json": { + "name": "kind" + } + }, + "isHttpMetadata": false, + "isExactName": false + }, + "properties": [ + { + "$ref": "56" + }, + { + "$id": "58", + "kind": "property", + "name": "size", + "serializedName": "size", + "type": { + "$id": "59", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Fish.size", + "serializationOptions": { + "json": { + "name": "size" + } + }, + "isHttpMetadata": false, + "isExactName": false + } + ] } ], "clients": [ { - "$id": "51", + "$id": "60", "kind": "client", "name": "SingleDiscriminatorClient", "isExactName": false, @@ -691,21 +798,21 @@ "doc": "Illustrates inheritance with single discriminator.", "methods": [ { - "$id": "52", + "$id": "61", "kind": "basic", "name": "getModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "53", + "$id": "62", "name": "getModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "54", + "$id": "63", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -721,7 +828,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getModel.accept", "methodParameterSegments": [ { - "$id": "55", + "$id": "64", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -748,7 +855,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -774,12 +881,12 @@ }, "parameters": [ { - "$ref": "55" + "$ref": "64" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -788,21 +895,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getModel" }, { - "$id": "56", + "$id": "65", "kind": "basic", "name": "putModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "57", + "$id": "66", "name": "putModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "58", + "$id": "67", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -819,7 +926,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel.contentType", "methodParameterSegments": [ { - "$id": "59", + "$id": "68", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -841,12 +948,12 @@ "isExactName": false }, { - "$id": "60", + "$id": "69", "kind": "body", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "isApiVersion": false, "contentTypes": [ @@ -860,12 +967,12 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel.input", "methodParameterSegments": [ { - "$id": "61", + "$id": "70", "kind": "method", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "location": "Body", "isApiVersion": false, @@ -911,10 +1018,10 @@ }, "parameters": [ { - "$ref": "61" + "$ref": "70" }, { - "$ref": "59" + "$ref": "68" } ], "response": {}, @@ -924,21 +1031,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putModel" }, { - "$id": "62", + "$id": "71", "kind": "basic", "name": "getRecursiveModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "63", + "$id": "72", "name": "getRecursiveModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "64", + "$id": "73", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -954,7 +1061,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel.accept", "methodParameterSegments": [ { - "$id": "65", + "$id": "74", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -981,7 +1088,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1007,12 +1114,12 @@ }, "parameters": [ { - "$ref": "65" + "$ref": "74" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1021,21 +1128,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel" }, { - "$id": "66", + "$id": "75", "kind": "basic", "name": "putRecursiveModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "67", + "$id": "76", "name": "putRecursiveModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "68", + "$id": "77", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -1052,7 +1159,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel.contentType", "methodParameterSegments": [ { - "$id": "69", + "$id": "78", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -1074,12 +1181,12 @@ "isExactName": false }, { - "$id": "70", + "$id": "79", "kind": "body", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "isApiVersion": false, "contentTypes": [ @@ -1093,12 +1200,12 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel.input", "methodParameterSegments": [ { - "$id": "71", + "$id": "80", "kind": "method", "name": "input", "serializedName": "input", "type": { - "$ref": "25" + "$ref": "29" }, "location": "Body", "isApiVersion": false, @@ -1144,10 +1251,10 @@ }, "parameters": [ { - "$ref": "71" + "$ref": "80" }, { - "$ref": "69" + "$ref": "78" } ], "response": {}, @@ -1157,21 +1264,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel" }, { - "$id": "72", + "$id": "81", "kind": "basic", "name": "getMissingDiscriminator", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "73", + "$id": "82", "name": "getMissingDiscriminator", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "74", + "$id": "83", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1187,7 +1294,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator.accept", "methodParameterSegments": [ { - "$id": "75", + "$id": "84", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1214,7 +1321,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1240,12 +1347,12 @@ }, "parameters": [ { - "$ref": "75" + "$ref": "84" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1254,21 +1361,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator" }, { - "$id": "76", + "$id": "85", "kind": "basic", "name": "getWrongDiscriminator", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "77", + "$id": "86", "name": "getWrongDiscriminator", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "78", + "$id": "87", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1284,7 +1391,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator.accept", "methodParameterSegments": [ { - "$id": "79", + "$id": "88", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1311,7 +1418,7 @@ 200 ], "bodyType": { - "$ref": "25" + "$ref": "29" }, "headers": [], "isErrorResponse": false, @@ -1337,12 +1444,12 @@ }, "parameters": [ { - "$ref": "79" + "$ref": "88" } ], "response": { "type": { - "$ref": "25" + "$ref": "29" } }, "isOverride": false, @@ -1351,21 +1458,21 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator" }, { - "$id": "80", + "$id": "89", "kind": "basic", "name": "getLegacyModel", "isExactName": false, "accessibility": "public", "apiVersions": [], "operation": { - "$id": "81", + "$id": "90", "name": "getLegacyModel", "isExactName": false, "resourceName": "SingleDiscriminator", "accessibility": "public", "parameters": [ { - "$id": "82", + "$id": "91", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -1381,7 +1488,7 @@ "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel.accept", "methodParameterSegments": [ { - "$id": "83", + "$id": "92", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -1408,7 +1515,7 @@ 200 ], "bodyType": { - "$ref": "44" + "$ref": "48" }, "headers": [], "isErrorResponse": false, @@ -1434,29 +1541,262 @@ }, "parameters": [ { - "$ref": "83" + "$ref": "92" } ], "response": { "type": { - "$ref": "44" + "$ref": "48" } }, "isOverride": false, "generateConvenient": true, "generateProtocol": true, "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel" + }, + { + "$id": "93", + "kind": "basic", + "name": "getNoSubtypesModel", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "94", + "name": "getNoSubtypesModel", + "isExactName": false, + "resourceName": "SingleDiscriminator", + "accessibility": "public", + "parameters": [ + { + "$id": "95", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel.accept", + "methodParameterSegments": [ + { + "$id": "96", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel.accept", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "55" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ], + "serializationOptions": { + "json": { + "name": "" + } + } + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/type/model/inheritance/single-discriminator/no-subtypes/model", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", + "decorators": [], + "namespace": "Type.Model.Inheritance.SingleDiscriminator" + }, + "parameters": [ + { + "$ref": "96" + } + ], + "response": { + "type": { + "$ref": "55" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel" + }, + { + "$id": "97", + "kind": "basic", + "name": "putNoSubtypesModel", + "isExactName": false, + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "98", + "name": "putNoSubtypesModel", + "isExactName": false, + "resourceName": "SingleDiscriminator", + "accessibility": "public", + "parameters": [ + { + "$id": "99", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "27" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.contentType", + "methodParameterSegments": [ + { + "$id": "100", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "27" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.contentType", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false + }, + { + "$id": "101", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "55" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.input", + "methodParameterSegments": [ + { + "$id": "102", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "55" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel.input", + "readOnly": false, + "access": "public", + "decorators": [], + "isExactName": false + } + ], + "isExactName": false, + "serializationOptions": { + "json": { + "name": "input" + } + } + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false, + "serializationOptions": {} + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/type/model/inheritance/single-discriminator/no-subtypes/model", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", + "decorators": [], + "namespace": "Type.Model.Inheritance.SingleDiscriminator" + }, + "parameters": [ + { + "$ref": "102" + }, + { + "$ref": "100" + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel" } ], "parameters": [ { - "$id": "84", + "$id": "103", "kind": "endpoint", "name": "endpoint", "serializedName": "endpoint", "doc": "Service host", "type": { - "$id": "85", + "$id": "104", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -1467,7 +1807,7 @@ "isEndpoint": true, "defaultValue": { "type": { - "$id": "86", + "$id": "105", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index 5bce2907224..c586240d276 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -12,24 +12,24 @@ "@azure/identity": "^4.13.0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/library-linter": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/library-linter": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/tspd": "0.74.2", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/tspd": "0.75.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "^10.1.2", @@ -38,15 +38,15 @@ "vitest": "^4.1.8" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": ">=0.68.0 <0.69.0 || ~0.69.0-0", - "@azure-tools/typespec-client-generator-core": ">=0.68.3 <0.69.0 || ~0.69.0-0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/sse": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/streams": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/versioning": ">=0.82.0 <0.83.0 || ~0.83.0-0" + "@azure-tools/typespec-azure-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/sse": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/streams": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/versioning": ">=0.83.0 <0.84.0 || ~0.84.0-0" } }, "node_modules/@alloy-js/core": { @@ -90,9 +90,9 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.40", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.40.tgz", - "integrity": "sha512-1WhoWwV+SgpzLUHJdRPo+Ph5mQNe0FtDYHb0dVBhIzRMjWzBvYhdj1iK0yAkwYnm04WxLO5izz5sO6/Lq5KhnQ==", + "version": "0.1.0-alpha.42", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.42.tgz", + "integrity": "sha512-vQOAepoGK1lSc9ohAub+NM1MiLJS5swIA5Ya3TTIJ4KkD1x6j5msdSRMgNgb0rmux/WWrKTRtsFDAiOF1Z0HKg==", "dev": true, "license": "MIT", "dependencies": { @@ -103,33 +103,33 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.68.0.tgz", - "integrity": "sha512-p0qUkRZav5fdQvGe2gSCvlgsvpM0y9xVhgH2GpXi5ZzpYfNGzxd8oZr8VOCP8mjMVfGQ3AtnowbmrHALEZgz7Q==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.69.0.tgz", + "integrity": "sha512-UNdPb/DgMvXqwWk9hb54QOAumCJ6u6GGy+bj3RIIT1Sht6FR9rIn8AQ/UQ7WtrhbJBoqvQo5dxtS565a9/VRZw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.3", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.3.tgz", - "integrity": "sha512-+OdRM36SJYZRZl8wrtLzkS6KfK5C2Y+V6NpSJxyZALp4PZghCaCHhage94DavgfjcODG+PMPoLEP4uFomMlQyw==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.69.0.tgz", + "integrity": "sha512-ro8zzOeiN/74r0wM19R77gzLtbfjIFgKgr1Rusii/vhCfJIoVC7IcqLxhbJl0RVkjyhRFKt4GCRAw4iurnrDnw==", "dev": true, "license": "MIT", "dependencies": { @@ -141,16 +141,16 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/sse": "^0.82.0", - "@typespec/streams": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/sse": "^0.83.0", + "@typespec/streams": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure/abort-controller": { @@ -1668,9 +1668,9 @@ } }, "node_modules/@typespec/compiler": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.12.0.tgz", - "integrity": "sha512-hKCkHEEDdCpXFyOU8ln+TzBBwonFMbkeUV0zIc+vBETyO8p/Upui3XvEyLOyB4CpKUReHzGeGm3gcFjNc73ygg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.13.0.tgz", + "integrity": "sha512-DonoHiyAMx0UjSmssqTrFtya+v97wny1aHcTLU5QF2wFzLATtcwUU9hbPC+eXhepuTunMOCHf8yk3pEsH6PZYA==", "dev": true, "license": "MIT", "dependencies": { @@ -1700,9 +1700,9 @@ } }, "node_modules/@typespec/events": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.82.0.tgz", - "integrity": "sha512-4gxwWndMVmYF6e5ETrwW6b77h1DsSc2ZiIbNo98XePaynD6yz/ooHKKtNKacjC2gmWhfRz1ArPioYn0YHvQkxw==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.83.0.tgz", + "integrity": "sha512-3EP1EIjdLgwStgd2rGWaF/QqY7YRAt+DIYnnYG2VsdPwa8s2t6K6eJ9YJDXveeHImAkHs+cpFuwxnjKMl4hOyw==", "dev": true, "license": "MIT", "peer": true, @@ -1710,21 +1710,21 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/http": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.12.0.tgz", - "integrity": "sha512-3Bb1M6VSuEVPWOecXj3h3I/ddMpb9cmKRQQq34oq7LatiK4fwVBp+EdWbqzEzaRUGHm9mZtqsMsxZf5FndT8dg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.13.0.tgz", + "integrity": "sha512-tf8XFddU6g1MZSAVCLC/0Xa4fNfUO0CcHe6PWpmC3bvUojxMnpRcERI2DdoRJ+aycB9Q+Z8wN8bJO3up6u+sCw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/streams": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -1733,9 +1733,9 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.37", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37.tgz", - "integrity": "sha512-XOIr51yuGVGMjr83OlpaeXWv2CSV+nnFZl8+Evws/M3DZfpQhMmbl7bSVYu378kCjFCw2JNLlob9e3fzJxaNdg==", + "version": "0.1.0-alpha.38", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38.tgz", + "integrity": "sha512-/DlR8P93iFhULlLYDUy+aSkOW2udDrHdIfdIHko8aFnmfC5QGXE2fcFphtNlJHCQEYTdZwfAxmBu/TsEygR8jw==", "dev": true, "license": "MIT", "dependencies": { @@ -1746,17 +1746,17 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@typespec/json-schema": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.12.0.tgz", - "integrity": "sha512-e/hxD6q0ThpCmIXOt4wseC30dv1lWnmQJaDhsn6MJySNVpcfTw9xVgj40Oeygc3TC1nO5X0cICtkOqDV/FMFAw==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.13.0.tgz", + "integrity": "sha512-o5yxs4aGhfFTkVNAkpFlO3LP2O8kWHQUgBzZ0s6tcbFlElGH86jUsdesT8O5ijoA0Cpa//m39wwxIcmBB2DiiA==", "dev": true, "license": "MIT", "dependencies": { @@ -1767,48 +1767,48 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/library-linter": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.82.0.tgz", - "integrity": "sha512-sNTE+dzaoMxZMdCoUJ7L4kyBHeJUbNBDS5PY+ZyFdA9EOa3fzzd5v3dRFmlMWzvow10oAKH1tHh/c6AhFbIl5Q==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.83.0.tgz", + "integrity": "sha512-pivCXKxVUEM/1PHAVOTy4NpTUTg2AikSeXN5R3HeHhkboHS203sSdsussKgvKHi2QbsaCYt2srTN29/fo+HcyQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/openapi": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.12.0.tgz", - "integrity": "sha512-XtkCMPpzXFfuIzmx/BQrCMUCCk7d37lkqZe5ubJmvJ02Fr7yvAbofrgtNUZ1BbFe3TBBUS2nB3E3mjT3tE4zCQ==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.13.0.tgz", + "integrity": "sha512-omPc9n+LM2WvjYwnIf31RCxmG17fFUOVLBRsWg4T1mbcsNCj4grnNP7Lwt+irIZCiKtmLKxq3ViE7jYixCkZ3g==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/rest": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.82.0.tgz", - "integrity": "sha512-cKjKEd8lgE3EdU9b5xXLoSdKBcifITOhHS2n9LPbEG9w6APfWDWGdtUe4UKV3wxWq9HlT143wpECW7IjrPhjnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.83.0.tgz", + "integrity": "sha512-WMEwEe1kdaOdZ0c+ct5BVmTSBXkrPniUYDWCz3K52T4in2dNc7J6YGP6tL8bXgQz5B0CsP0VNO12N+UysQDsLw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/spec-api": { @@ -1939,32 +1939,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.82.0.tgz", - "integrity": "sha512-4jBByfLsS7yQAIqmbLkfrw4XoPm9kOqawvW5gVXmKtnMMDYR0RmfBhsnAXBqhUXGbnFq0bDJGEw3GX+6k3mKnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.83.0.tgz", + "integrity": "sha512-04WNaju2rwBbcF5pG+HrKQtdcrmSGuTVziLHNA9XOqj1qM7Uon3+wo2g+ZZ3Z6tngfqQoTCPyDcRHqZtGRdNuw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/streams": "^0.83.0" } }, "node_modules/@typespec/streams": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.82.0.tgz", - "integrity": "sha512-cr/6h6VV/6OJeG8RNcSd0SDes5iEXiuGUcKGrMN6wF8qKTTrY2hXNhfqCCn3lamDOg00wbi7ke+laz6pHWN3tg==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.83.0.tgz", + "integrity": "sha512-wbO6sdH1Uf+UwjxxsWdHQkjJ3wwiYsAKI+L66qnDYVXAFe02sUdMKd0mxH5o9ipGXE52MZ+yvZ52vHAD+g3RFQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -1982,9 +1982,9 @@ } }, "node_modules/@typespec/tspd": { - "version": "0.74.2", - "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.74.2.tgz", - "integrity": "sha512-R7JK1H7xD/1dced4GKpbiMn/r7f1xwNMbIT9o2+XlohUCyA+MPnGvy8KVUYmv16ZUKwI9V6/RDysOFSgqdg07w==", + "version": "0.75.0", + "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.75.0.tgz", + "integrity": "sha512-lGCpN5aM1O8utVH+6c7UMv9IZtEKlxc4O5blxp06TdnYWjOxyOEm+R9BBzaY7aq6Jtj/YamdDnMvzV42y/F10Q==", "dev": true, "license": "MIT", "dependencies": { @@ -1995,7 +1995,7 @@ "@microsoft/api-extractor-model": "^7.33.5", "@microsoft/tsdoc": "^0.16.0", "@microsoft/tsdoc-config": "^0.18.1", - "@typespec/compiler": "^1.12.0", + "@typespec/compiler": "^1.13.0", "picocolors": "^1.1.1", "prettier": "^3.8.1", "typedoc": "^0.28.19", @@ -2011,29 +2011,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.82.0.tgz", - "integrity": "sha512-s8giuYQTQPniy2YxNfKXYpAU2Vm4L74TdOsbFWe0tG+jnOy/9tt7kKTH4QF1sB8nRvmjv8h31EoHtZYOPe1GvA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.83.0.tgz", + "integrity": "sha512-nE66ta0ixpHB6FQpSzqnj8QnVfgFsxeK/4Xv+DxYx2nB/w18f6VjkF+hW+A/zs1tZIYvBZVbCNa/Rcr8zM6fhg==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/xml": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.82.0.tgz", - "integrity": "sha512-/Bwlt7HwSltojSbalkh7hGRh/lB5aMJllnb7gAAf3xRPMlnmu5VJqDFFcbZKqDvkwgGXZX/xHo458c4kott5Ug==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.83.0.tgz", + "integrity": "sha512-2/dtAD8jGPkIdwpQ1G1P+5+qdMPeafQiIKCd8NdAnOo0w9OZ59Io52jINm9HdN8+FcbOrqK8+B2N9rlPRj7PqA==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@vitest/coverage-v8": { diff --git a/packages/http-client-csharp/package.json b/packages/http-client-csharp/package.json index f91b1e27035..f90454931af 100644 --- a/packages/http-client-csharp/package.json +++ b/packages/http-client-csharp/package.json @@ -58,35 +58,35 @@ "emitter/lib/*.tsp" ], "peerDependencies": { - "@azure-tools/typespec-azure-core": ">=0.68.0 <0.69.0 || ~0.69.0-0", - "@azure-tools/typespec-client-generator-core": ">=0.68.3 <0.69.0 || ~0.69.0-0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/sse": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/streams": ">=0.82.0 <0.83.0 || ~0.83.0-0", - "@typespec/versioning": ">=0.82.0 <0.83.0 || ~0.83.0-0" + "@azure-tools/typespec-azure-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <0.70.0 || ~0.70.0-0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/sse": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/streams": ">=0.83.0 <0.84.0 || ~0.84.0-0", + "@typespec/versioning": ">=0.83.0 <0.84.0 || ~0.84.0-0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/library-linter": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/library-linter": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/tspd": "0.74.2", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/tspd": "0.75.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "^10.1.2", diff --git a/packages/http-client-csharp/readme.md b/packages/http-client-csharp/readme.md index beb26cda25e..2dba2aaa57b 100644 --- a/packages/http-client-csharp/readme.md +++ b/packages/http-client-csharp/readme.md @@ -127,7 +127,7 @@ Allows emitter authors to specify the path to a custom emitter package, allowing ### `plugins` -**Type:** `array` +**Type:** `string[]` Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: @@ -142,10 +142,20 @@ options: ### `license` -**Type:** `object` +**Type:** `object { name, company, link, header, description }` License information for the generated client code. +**Properties:** + +| Name | Type | Default | Description | +| ------------- | -------- | ------- | ----------- | +| `name` | `string` | | | +| `company` | `string` | | | +| `link` | `string` | | | +| `header` | `string` | | | +| `description` | `string` | | | + ### `sdk-context-options` **Type:** `object` diff --git a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md index 10b52769c33..e356043f01e 100644 --- a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md +++ b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md @@ -110,7 +110,7 @@ Allows emitter authors to specify the path to a custom emitter package, allowing ### `plugins` -**Type:** `array` +**Type:** `string[]` Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends `GeneratorPlugin`. Paths may be absolute or relative to the resolved `emitter-output-dir`. For example, to load plugins that live in a `codegen` folder under the output directory: @@ -125,10 +125,20 @@ options: ### `license` -**Type:** `object` +**Type:** `object { name, company, link, header, description }` License information for the generated client code. +**Properties:** + +| Name | Type | Default | Description | +| ------------- | -------- | ------- | ----------- | +| `name` | `string` | | | +| `company` | `string` | | | +| `link` | `string` | | | +| `header` | `string` | | | +| `description` | `string` | | | + ### `sdk-context-options` **Type:** `object` diff --git a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/index.mdx b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/index.mdx index ca373e97796..2a35e9280e5 100644 --- a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/index.mdx +++ b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/index.mdx @@ -32,8 +32,6 @@ npm install --save-peer @typespec/http-client-csharp [See documentation](./emitter.md) -## TypeSpec.HttpClient - ## TypeSpec.HttpClient.CSharp ### Decorators From ccf14f6a706af380b231c50505cefd8d9138fa83 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 10 Jun 2026 15:52:01 -0700 Subject: [PATCH 09/29] fix(http-client-csharp): strip [Experimental] attribute when internalizing types (#10958) ## Problem Public types are tagged with `[Experimental]` during the visitor phase (`CSharpGen` runs visitors before `PostProcessAsync`). The post-processor later internalizes types that are not reachable from the public API surface, but `MarkInternal` only changed the `public` -> `internal` modifier token and left the already-written `[Experimental]` attribute in place. The result was a public-API stability attribute on `internal` types (e.g. `InternalProjectsClientOptions` and various model-factory internals), which is meaningless on non-public types and produces spurious diff churn. ## Fix `MarkInternal` now also strips the `[Experimental]` (`System.Diagnostics.CodeAnalysis.ExperimentalAttribute`) attribute when internalizing a type: - Matches both `Experimental` and `ExperimentalAttribute`, including qualified names. - Preserves other attributes (e.g. trims a combined `[Serializable, Experimental]` list down to `[Serializable]`). - Re-attaches the declaration's original leading trivia so documentation comments and indentation are preserved (the internalize pass is not reformatted afterward). ### Logging - `Debug`: `Internalizing unreferenced public type ''.` - `Debug`: `Removed [Experimental] attribute from '' while internalizing it.` - `Info`: `Internalized N unreferenced public type(s).` ## Tests New `PostProcessorTests.RemovesExperimentalAttributeWhenInternalizing` covering: - referenced (public) type keeps `[Experimental]`; - unreferenced type is internalized and loses `[Experimental]`, doc comment preserved; - other attribute preserved when in a separate list; - other attribute preserved when combined in the same list. Full `Microsoft.TypeSpec.Generator` suite passes (1526 passed, 0 failed). --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/PostProcessing/PostProcessor.cs | 86 +++++++++++++++++ .../test/PostProcessing/PostProcessorTests.cs | 96 +++++++++++++++++++ .../ExperimentalInternalizeRoot.cs | 7 ++ .../ReferencedModel.cs | 12 +++ .../UnreferencedModel.cs | 12 +++ .../UnreferencedWithCombinedAttributes.cs | 13 +++ .../UnreferencedWithOtherAttribute.cs | 14 +++ 7 files changed, 240 insertions(+) create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs index be96e11df59..738174e7628 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs @@ -20,6 +20,8 @@ internal class PostProcessor private readonly HashSet _typesToKeep; private INamedTypeSymbol? _modelFactorySymbol; + private static readonly string[] _experimentalAttributeNames = ["Experimental", "ExperimentalAttribute"]; + public PostProcessor( HashSet typesToKeep, string? modelFactoryFullName = null, @@ -156,6 +158,12 @@ public async Task InternalizeAsync(Project project) project = MarkInternal(project, model, documentId); } + if (nodesToInternalize.Count > 0) + { + CodeModelGenerator.Instance.Emitter.Info( + $"Internalized {nodesToInternalize.Count} unreferenced public type(s)."); + } + var modelNamesToRemove = nodesToInternalize.Keys.Select(item => item.Identifier.Text); project = await RemoveMethodsFromModelFactoryAsync(project, definitions, modelNamesToRemove.ToHashSet()); @@ -336,7 +344,13 @@ private static IEnumerable GetReferencedTypes(T definition, private Project MarkInternal(Project project, BaseTypeDeclarationSyntax declarationNode, DocumentId documentId) { + CodeModelGenerator.Instance.Emitter.Debug( + $"Internalizing unreferenced public type '{declarationNode.Identifier.Text}'."); + var newNode = ChangeModifier(declarationNode, SyntaxKind.PublicKeyword, SyntaxKind.InternalKeyword); + // The [Experimental] attribute is a public-API stability signal that is meaningless on a type that is + // being internalized, so strip it to avoid emitting it (and its use-site diagnostics) on internal types. + newNode = RemoveExperimentalAttribute(newNode, declarationNode.Identifier.Text); var tree = declarationNode.SyntaxTree; var document = project.GetDocument(documentId)!; var newRoot = tree.GetRoot().ReplaceNode(declarationNode, newNode) @@ -345,6 +359,78 @@ private Project MarkInternal(Project project, BaseTypeDeclarationSyntax declarat return document.Project; } + /// + /// Removes any [Experimental] () + /// attribute from . The declaration's leading trivia (such as documentation + /// comments and indentation) is re-attached to the resulting first token so that the surrounding formatting and + /// any documentation comment are preserved even when the attribute that carried them is removed. + /// + private static BaseTypeDeclarationSyntax RemoveExperimentalAttribute( + BaseTypeDeclarationSyntax declarationNode, + string typeName) + { + if (declarationNode.AttributeLists.Count == 0) + { + return declarationNode; + } + + var newAttributeLists = new List(); + bool removed = false; + + foreach (var attributeList in declarationNode.AttributeLists) + { + var keptAttributes = attributeList.Attributes + .Where(attribute => !IsExperimentalAttribute(attribute)) + .ToList(); + + if (keptAttributes.Count == attributeList.Attributes.Count) + { + // Nothing removed from this list. + newAttributeLists.Add(attributeList); + } + else if (keptAttributes.Count > 0) + { + // Keep the remaining (non-experimental) attributes in this list. + removed = true; + newAttributeLists.Add(attributeList.WithAttributes(SyntaxFactory.SeparatedList(keptAttributes))); + } + else + { + // The entire list only contained experimental attributes and is dropped. + removed = true; + } + } + + if (!removed) + { + return declarationNode; + } + + CodeModelGenerator.Instance.Emitter.Debug( + $"Removed [Experimental] attribute from '{typeName}' while internalizing it."); + + // Preserve the original leading trivia (e.g. documentation comments and indentation) by re-attaching it to + // whatever token now leads the declaration. This keeps the doc comment even when it was attached to the + // attribute list that was removed. + var originalLeadingTrivia = declarationNode.GetLeadingTrivia(); + var newNode = declarationNode.WithAttributeLists(SyntaxFactory.List(newAttributeLists)); + var firstToken = newNode.GetFirstToken(); + + return newNode.ReplaceToken(firstToken, firstToken.WithLeadingTrivia(originalLeadingTrivia)); + } + + private static bool IsExperimentalAttribute(AttributeSyntax attribute) + { + var name = attribute.Name switch + { + QualifiedNameSyntax qualified => qualified.Right.Identifier.Text, + IdentifierNameSyntax identifier => identifier.Identifier.Text, + _ => attribute.Name.ToString() + }; + + return Array.IndexOf(_experimentalAttributeNames, name) >= 0; + } + private async Task RemoveModelsAsync(Project project, IEnumerable unusedModels) { diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs index 28981148a4d..ebd37a0c146 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs @@ -3,10 +3,12 @@ using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.TypeSpec.Generator.Tests.Common; using NUnit.Framework; @@ -289,6 +291,100 @@ public async Task DoesNotRemoveValidAttributes() Assert.AreEqual(Helpers.GetExpectedFromFile().TrimEnd(), output, "The output should match the expected content."); } + [Test] + public async Task RemovesExperimentalAttributeWhenInternalizing() + { + MockHelpers.LoadMockGenerator(); + var workspace = new AdhocWorkspace(); + var projectInfo = ProjectInfo.Create( + ProjectId.CreateNewId(), + VersionStamp.Create(), + name: "TestProj", + assemblyName: "TestProj", + language: LanguageNames.CSharp) + .WithMetadataReferences(new[] + { + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + MetadataReference.CreateFromFile(typeof(ExperimentalAttribute).Assembly.Location) + }); + + var project = workspace.AddProject(projectInfo); + var folder = Helpers.GetAssetFileOrDirectoryPath(false); + const string rootFileName = "ExperimentalInternalizeRoot.cs"; + string[] modelFileNames = + [ + "ReferencedModel.cs", + "UnreferencedModel.cs", + "UnreferencedWithOtherAttribute.cs", + "UnreferencedWithCombinedAttributes.cs" + ]; + foreach (var fileName in modelFileNames) + { + project = project.AddDocument( + fileName, + File.ReadAllText(Path.Join(folder, fileName))).Project; + } + project = project.AddDocument( + rootFileName, + File.ReadAllText(Path.Join(folder, rootFileName))).Project; + var postProcessor = new TestPostProcessor(rootFileName); + + var resultProject = await postProcessor.InternalizeAsync(project); + + var referencedModel = await GetSingleClassAsync(resultProject, "ReferencedModel.cs", "ReferencedModel"); + var unreferencedModel = await GetSingleClassAsync(resultProject, "UnreferencedModel.cs", "UnreferencedModel"); + var unreferencedWithOther = await GetSingleClassAsync(resultProject, "UnreferencedWithOtherAttribute.cs", "UnreferencedWithOtherAttribute"); + var unreferencedWithCombined = await GetSingleClassAsync(resultProject, "UnreferencedWithCombinedAttributes.cs", "UnreferencedWithCombinedAttributes"); + + // The referenced model stays public and keeps its [Experimental] attribute. + Assert.IsTrue(referencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword))); + Assert.IsTrue(HasExperimentalAttribute(referencedModel), "Referenced (public) model should keep [Experimental]."); + + // The unreferenced model is internalized and loses its [Experimental] attribute. + Assert.IsTrue(unreferencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); + Assert.IsFalse(unreferencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword))); + Assert.IsFalse(HasExperimentalAttribute(unreferencedModel), "Internalized model should not keep [Experimental]."); + + // The documentation comment on the internalized type is preserved. + Assert.IsTrue( + unreferencedModel.GetLeadingTrivia().ToFullString().Contains("not referenced"), + "Doc comment of the internalized type should be preserved."); + + // An internalized type with another attribute in a separate list keeps the other attribute. + Assert.IsTrue(unreferencedWithOther.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); + Assert.IsFalse(HasExperimentalAttribute(unreferencedWithOther), "Internalized model should not keep [Experimental]."); + Assert.IsTrue(HasAttribute(unreferencedWithOther, "Serializable"), "Other attributes should be preserved."); + Assert.IsTrue( + unreferencedWithOther.GetLeadingTrivia().ToFullString().Contains("must be preserved"), + "Doc comment should be preserved when only one of several attribute lists is removed."); + + // An internalized type with the experimental attribute combined in a single list keeps the others. + Assert.IsTrue(unreferencedWithCombined.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); + Assert.IsFalse(HasExperimentalAttribute(unreferencedWithCombined), "Internalized model should not keep [Experimental]."); + Assert.IsTrue(HasAttribute(unreferencedWithCombined, "Serializable"), "Other attributes in the same list should be preserved."); + } + + private static async Task GetSingleClassAsync(Project project, string fileName, string className) + { + var doc = project.Documents.Single(d => d.Name == fileName); + var root = await doc.GetSyntaxRootAsync(); + return ((CompilationUnitSyntax)root!) + .DescendantNodes() + .OfType() + .Single(t => t.Identifier.Text == className); + } + + private static bool HasAttribute(BaseTypeDeclarationSyntax type, string attributeName) + => type.AttributeLists + .SelectMany(list => list.Attributes) + .Any(attr => attr.Name.ToString() == attributeName); + + + private static bool HasExperimentalAttribute(BaseTypeDeclarationSyntax type) + => type.AttributeLists + .SelectMany(list => list.Attributes) + .Any(attr => attr.Name.ToString() is "Experimental" or "ExperimentalAttribute"); + private class TestPostProcessor : PostProcessor { private readonly string _rootFile; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs new file mode 100644 index 00000000000..350fb5fdbba --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs @@ -0,0 +1,7 @@ +namespace Sample +{ + public class ExperimentalInternalizeRoot + { + public ReferencedModel Model { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs new file mode 100644 index 00000000000..877443f345a --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs @@ -0,0 +1,12 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Sample +{ + /// + /// A model that is referenced from a root type and therefore stays public. + /// + [Experimental("EXP001")] + public class ReferencedModel + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs new file mode 100644 index 00000000000..727b2c097d4 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs @@ -0,0 +1,12 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Sample +{ + /// + /// A model that is not referenced from any root type and is internalized. + /// + [Experimental("EXP001")] + public class UnreferencedModel + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs new file mode 100644 index 00000000000..5a2afab2013 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs @@ -0,0 +1,13 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Sample +{ + /// + /// An unreferenced model with the experimental attribute combined in a single list. + /// + [Serializable, Experimental("EXP001")] + public class UnreferencedWithCombinedAttributes + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs new file mode 100644 index 00000000000..5d970ad6d99 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs @@ -0,0 +1,14 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Sample +{ + /// + /// An unreferenced model that carries another attribute which must be preserved. + /// + [Serializable] + [Experimental("EXP001")] + public class UnreferencedWithOtherAttribute + { + } +} From cd228214813f9191e0e8d542d9c700603e1c9365 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 10:28:23 +0800 Subject: [PATCH 10/29] fix(http-client-java): align query tests with ConstantClient builder API (#10953) `mvn compile test` failed in both Java test modules because `parameters/query/QueryTests` still referenced removed `QueryClient` construction paths. This updates the tests to use the currently generated query client surface. - **What changed** - Updated `QueryTests` in both modules: - `generator/http-client-generator-test` - `generator/http-client-generator-clientcore-test` - Replaced obsolete `QueryClient` instantiation with `ConstantClient` from `QueryClientBuilder.buildConstantClient()`. - **Why this resolves the issue** - The generated `parameters.query` package exposes `ConstantClient`/`SpecialCharClient` builders, not a `QueryClient` type or `buildClient`/`buildQueryClient` methods. - Tests now target the actual generated API contract. - **Code change example** ```java // before private final QueryClient client = new QueryClientBuilder().buildClient(); // after private final ConstantClient client = new QueryClientBuilder().buildConstantClient(); ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> Co-authored-by: Weidong Xu --- ...ent-java-update-deps-2026-6-10-15-41-00.md | 7 + .../package.json | 32 +- .../parameters/bodyroot/BodyRootClient.java | 66 ++ .../bodyroot/BodyRootClientBuilder.java | 235 ++++++ .../parameters/bodyroot/BodyRootModel.java | 150 ++++ .../implementation/BodyRootClientImpl.java | 129 +++ .../bodyroot/implementation/package-info.java | 5 + .../parameters/bodyroot/package-info.java | 5 + .../{QueryClient.java => ConstantClient.java} | 6 +- .../parameters/query/QueryClientBuilder.java | 21 +- .../parameters/query/SpecialCharClient.java | 66 ++ .../query/implementation/QueryClientImpl.java | 15 + .../implementation/SpecialCharsImpl.java | 92 +++ .../inheritance/singlediscriminator/Fish.java | 102 +++ .../SingleDiscriminatorClient.java | 62 ++ .../SingleDiscriminatorClientImpl.java | 55 ++ .../parameters-bodyroot_metadata.json | 1 + .../META-INF/parameters-query_metadata.json | 2 +- ...eritance-singlediscriminator_metadata.json | 2 +- .../java/parameters/query/QueryTests.java | 2 +- .../http-client-generator-test/package.json | 32 +- .../CommonPropertiesManager.java | 17 + .../fluent/ArmResourceIdentifiersClient.java | 77 ++ .../fluent/CommonPropertiesClient.java | 7 + .../ArmResourceIdentifierResourceInner.java | 183 +++++ .../ArmResourceIdentifierResourceImpl.java | 146 ++++ .../ArmResourceIdentifiersClientImpl.java | 260 ++++++ .../ArmResourceIdentifiersImpl.java | 90 +++ .../CommonPropertiesClientImpl.java | 16 + .../models/ArmResourceIdentifierResource.java | 200 +++++ ...mResourceIdentifierResourceProperties.java | 189 +++++ .../models/ArmResourceIdentifiers.java | 71 ++ .../models/ResourceProvisioningState.java | 56 ++ .../ManagementGroupManager.java | 282 +++++++ .../ManagementGroupChildResourcesClient.java | 198 +++++ .../fluent/ManagementGroupClient.java | 48 ++ .../ManagementGroupChildResourceInner.java | 157 ++++ .../fluent/models/package-info.java | 9 + .../managementgroup/fluent/package-info.java | 9 + .../ManagementGroupChildResourceImpl.java | 50 ++ ...nagementGroupChildResourcesClientImpl.java | 758 ++++++++++++++++++ .../ManagementGroupChildResourcesImpl.java | 120 +++ .../ManagementGroupClientBuilder.java | 122 +++ .../ManagementGroupClientImpl.java | 292 +++++++ .../implementation/ResourceManagerUtils.java | 195 +++++ ...anagementGroupChildResourceListResult.java | 98 +++ .../implementation/package-info.java | 9 + .../models/ManagementGroupChildResource.java | 55 ++ ...anagementGroupChildResourceProperties.java | 104 +++ .../models/ManagementGroupChildResources.java | 150 ++++ .../models/ProvisioningState.java | 76 ++ .../managementgroup/models/package-info.java | 9 + .../managementgroup/package-info.java | 9 + .../bodyroot/BodyRootAsyncClient.java | 88 ++ .../parameters/bodyroot/BodyRootClient.java | 85 ++ .../bodyroot/BodyRootClientBuilder.java | 287 +++++++ .../implementation/BodyRootClientImpl.java | 205 +++++ .../bodyroot/implementation/package-info.java | 11 + .../bodyroot/models/BodyRootModel.java | 154 ++++ .../bodyroot/models/package-info.java | 11 + .../parameters/bodyroot/package-info.java | 11 + ...ncClient.java => ConstantAsyncClient.java} | 6 +- .../{QueryClient.java => ConstantClient.java} | 6 +- .../parameters/query/QueryClientBuilder.java | 43 +- .../query/SpecialCharAsyncClient.java | 75 ++ .../parameters/query/SpecialCharClient.java | 72 ++ .../query/implementation/QueryClientImpl.java | 15 + .../implementation/SpecialCharsImpl.java | 110 +++ .../SingleDiscriminatorAsyncClient.java | 94 +++ .../SingleDiscriminatorClient.java | 91 +++ .../SingleDiscriminatorClientImpl.java | 147 ++++ .../singlediscriminator/models/Fish.java | 106 +++ ...r-commonproperties-generated_metadata.json | 2 +- ...er-managementgroup-generated_metadata.json | 1 + .../proxy-config.json | 2 +- .../proxy-config.json | 1 + .../reflect-config.json | 1 + .../parameters-bodyroot_metadata.json | 1 + .../META-INF/parameters-query_metadata.json | 2 +- ...eritance-singlediscriminator_metadata.json | 2 +- ...nager-managementgroup-generated.properties | 1 + .../resources/parameters-bodyroot.properties | 2 + .../generated/BodyRootClientTestBase.java | 34 + .../java/parameters/query/QueryTests.java | 2 +- .../query/generated/QueryClientTestBase.java | 22 +- packages/http-client-java/package-lock.json | 234 +++--- packages/http-client-java/package.json | 56 +- 87 files changed, 6916 insertions(+), 213 deletions(-) create mode 100644 .chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java rename packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/{QueryClient.java => ConstantClient.java} (93%) create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java rename packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/{QueryAsyncClient.java => ConstantAsyncClient.java} (95%) rename packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/{QueryClient.java => ConstantClient.java} (95%) create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java diff --git a/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md b/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md new file mode 100644 index 00000000000..5d20285f5be --- /dev/null +++ b/.chronus/changes/http-client-java-update-deps-2026-6-10-15-41-00.md @@ -0,0 +1,7 @@ +--- +changeKind: dependencies +packages: + - "@typespec/http-client-java" +--- + +Update Node.js dependencies to latest (compiler 1.13.0, TCGC 0.69.0, azure-core 0.69.0) and bump version to 0.9.0 diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json index 2a35b90075a..782e18e5756 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -14,25 +14,25 @@ "dependencies": { "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", - "@typespec/http-specs": "0.1.0-alpha.37", - "@typespec/json-schema": "1.12.0", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.8.1.tgz", + "@typespec/http-specs": "0.1.0-alpha.38", + "@typespec/json-schema": "1.13.0", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.9.0.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/rest": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/xml": "0.82.0", - "@typespec/events": "0.82.0", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-autorest": "0.68.0" + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/rest": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/xml": "0.83.0", + "@typespec/events": "0.83.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-autorest": "0.69.0" }, "private": true } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java new file mode 100644 index 00000000000..085d6d8f135 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClient.java @@ -0,0 +1,66 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceClient; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.instrumentation.Instrumentation; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * Initializes a new instance of the synchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class) +public final class BodyRootClient { + @Metadata(properties = { MetadataProperties.GENERATED }) + private final BodyRootClientImpl serviceClient; + + private final Instrumentation instrumentation; + + /** + * Initializes an instance of BodyRootClient class. + * + * @param serviceClient the service client implementation. + * @param instrumentation the instrumentation instance. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + BodyRootClient(BodyRootClientImpl serviceClient, Instrumentation instrumentation) { + this.serviceClient = serviceClient; + this.instrumentation = instrumentation; + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BodyRootModel bodyRootParameters, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.BodyRoot.nested", requestContext, + updatedContext -> this.serviceClient.nestedWithResponse(bodyRootParameters, updatedContext)); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void nested(BodyRootModel bodyRootParameters) { + nestedWithResponse(bodyRootParameters, RequestContext.none()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java new file mode 100644 index 00000000000..649503e296a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java @@ -0,0 +1,235 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpInstrumentationOptions; +import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectOptions; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryOptions; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.instrumentation.Instrumentation; +import io.clientcore.core.instrumentation.SdkInstrumentationOptions; +import io.clientcore.core.traits.ConfigurationTrait; +import io.clientcore.core.traits.EndpointTrait; +import io.clientcore.core.traits.HttpTrait; +import io.clientcore.core.traits.ProxyTrait; +import io.clientcore.core.utils.CoreUtils; +import io.clientcore.core.utils.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * A builder for creating a new instance of the BodyRootClient type. + */ +@ServiceClientBuilder(serviceClients = { BodyRootClient.class }) +public final class BodyRootClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final String SDK_NAME = "name"; + + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final String SDK_VERSION = "version"; + + @Metadata(properties = { MetadataProperties.GENERATED }) + private static final Map PROPERTIES = CoreUtils.getProperties("parameters-bodyroot.properties"); + + @Metadata(properties = { MetadataProperties.GENERATED }) + private final List pipelinePolicies; + + /** + * Create an instance of the BodyRootClientBuilder. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The instrumentation configuration for HTTP requests and responses. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpInstrumentationOptions httpInstrumentationOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder httpInstrumentationOptions(HttpInstrumentationOptions httpInstrumentationOptions) { + this.httpInstrumentationOptions = httpInstrumentationOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public BodyRootClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of BodyRootClientImpl with the provided parameters. + * + * @return an instance of BodyRootClientImpl. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private BodyRootClientImpl buildInnerClient() { + this.validateClient(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null + ? new HttpInstrumentationOptions() + : this.httpInstrumentationOptions; + SdkInstrumentationOptions sdkInstrumentationOptions + = new SdkInstrumentationOptions(PROPERTIES.getOrDefault(SDK_NAME, "UnknownName")) + .setSdkVersion(PROPERTIES.get(SDK_VERSION)) + .setEndpoint(localEndpoint); + Instrumentation instrumentation + = Instrumentation.create(localHttpInstrumentationOptions, sdkInstrumentationOptions); + BodyRootClientImpl client = new BodyRootClientImpl(createHttpPipeline(), instrumentation, localEndpoint); + return client; + } + + @Metadata(properties = { MetadataProperties.GENERATED }) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(properties = { MetadataProperties.GENERATED }) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpInstrumentationOptions localHttpInstrumentationOptions = this.httpInstrumentationOptions == null + ? new HttpInstrumentationOptions() + : this.httpInstrumentationOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpInstrumentationPolicy(localHttpInstrumentationOptions)); + policies.forEach(httpPipelineBuilder::addPolicy); + return httpPipelineBuilder.httpClient(httpClient).build(); + } + + /** + * Builds an instance of BodyRootClient class. + * + * @return an instance of BodyRootClient. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootClient buildClient() { + BodyRootClientImpl innerClient = buildInnerClient(); + return new BodyRootClient(innerClient, innerClient.getInstrumentation()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java new file mode 100644 index 00000000000..e37cce00e86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/BodyRootModel.java @@ -0,0 +1,150 @@ +package parameters.bodyroot; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The BodyRootModel model. + */ +@Metadata(properties = { MetadataProperties.FLUENT }) +public final class BodyRootModel implements JsonSerializable { + /* + * The category property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String category; + + /* + * The linkType property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String linkType; + + /* + * The wasSuccessful property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private Boolean wasSuccessful; + + /** + * Creates an instance of BodyRootModel class. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel() { + } + + /** + * Get the category property: The category property. + * + * @return the category value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getCategory() { + return this.category; + } + + /** + * Set the category property: The category property. + * + * @param category the category value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setCategory(String category) { + this.category = category; + return this; + } + + /** + * Get the linkType property: The linkType property. + * + * @return the linkType value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getLinkType() { + return this.linkType; + } + + /** + * Set the linkType property: The linkType property. + * + * @param linkType the linkType value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setLinkType(String linkType) { + this.linkType = linkType; + return this; + } + + /** + * Get the wasSuccessful property: The wasSuccessful property. + * + * @return the wasSuccessful value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public Boolean isWasSuccessful() { + return this.wasSuccessful; + } + + /** + * Set the wasSuccessful property: The wasSuccessful property. + * + * @param wasSuccessful the wasSuccessful value to set. + * @return the BodyRootModel object itself. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public BodyRootModel setWasSuccessful(Boolean wasSuccessful) { + this.wasSuccessful = wasSuccessful; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("category", this.category); + jsonWriter.writeStringField("linkType", this.linkType); + jsonWriter.writeBooleanField("wasSuccessful", this.wasSuccessful); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyRootModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyRootModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BodyRootModel. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public static BodyRootModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BodyRootModel deserializedBodyRootModel = new BodyRootModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("category".equals(fieldName)) { + deserializedBodyRootModel.category = reader.getString(); + } else if ("linkType".equals(fieldName)) { + deserializedBodyRootModel.linkType = reader.getString(); + } else if ("wasSuccessful".equals(fieldName)) { + deserializedBodyRootModel.wasSuccessful = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedBodyRootModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java new file mode 100644 index 00000000000..51f1961f020 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java @@ -0,0 +1,129 @@ +package parameters.bodyroot.implementation; + +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceInterface; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.annotations.BodyParam; +import io.clientcore.core.http.annotations.HeaderParam; +import io.clientcore.core.http.annotations.HostParam; +import io.clientcore.core.http.annotations.HttpRequestInformation; +import io.clientcore.core.http.annotations.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.instrumentation.Instrumentation; +import java.lang.reflect.InvocationTargetException; +import parameters.bodyroot.BodyRootModel; + +/** + * Initializes a new instance of the BodyRootClient type. + */ +public final class BodyRootClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyRootClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The instance of instrumentation to report telemetry. + */ + private final Instrumentation instrumentation; + + /** + * Gets The instance of instrumentation to report telemetry. + * + * @return the instrumentation value. + */ + public Instrumentation getInstrumentation() { + return this.instrumentation; + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param instrumentation The instance of instrumentation to report telemetry. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, Instrumentation instrumentation, String endpoint) { + this.httpPipeline = httpPipeline; + this.instrumentation = instrumentation; + this.endpoint = endpoint; + this.service = BodyRootClientService.getNewInstance(this.httpPipeline); + } + + /** + * The interface defining all the services for BodyRootClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "BodyRootClient", host = "{endpoint}") + public interface BodyRootClientService { + static BodyRootClientService getNewInstance(HttpPipeline pipeline) { + try { + Class clazz = Class.forName("parameters.bodyroot.implementation.BodyRootClientServiceImpl"); + return (BodyRootClientService) clazz.getMethod("getNewInstance", HttpPipeline.class) + .invoke(null, pipeline); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-root/nested", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response nested(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BodyRootModel bodyRootParameters, RequestContext requestContext); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BodyRootModel bodyRootParameters, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.BodyRoot.nested", requestContext, + updatedContext -> { + final String contentType = "application/json"; + return service.nested(this.getEndpoint(), contentType, bodyRootParameters, updatedContext); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java new file mode 100644 index 00000000000..970e0838ae1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/implementation/package-info.java @@ -0,0 +1,5 @@ +/** + * Package containing the implementations for BodyRoot. + * Test for @bodyRoot parameter patterns. + */ +package parameters.bodyroot.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java new file mode 100644 index 00000000000..5130971aeac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyroot/package-info.java @@ -0,0 +1,5 @@ +/** + * Package containing the classes for BodyRoot. + * Test for @bodyRoot parameter patterns. + */ +package parameters.bodyroot; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java similarity index 93% rename from packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java rename to packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java index 6941ae352f6..0f7e7d4c32c 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClient.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/ConstantClient.java @@ -15,20 +15,20 @@ * Initializes a new instance of the synchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class) -public final class QueryClient { +public final class ConstantClient { @Metadata(properties = { MetadataProperties.GENERATED }) private final ConstantsImpl serviceClient; private final Instrumentation instrumentation; /** - * Initializes an instance of QueryClient class. + * Initializes an instance of ConstantClient class. * * @param serviceClient the service client implementation. * @param instrumentation the instrumentation instance. */ @Metadata(properties = { MetadataProperties.GENERATED }) - QueryClient(ConstantsImpl serviceClient, Instrumentation instrumentation) { + ConstantClient(ConstantsImpl serviceClient, Instrumentation instrumentation) { this.serviceClient = serviceClient; this.instrumentation = instrumentation; } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java index 4bb9b538c9f..19f12b62b87 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/QueryClientBuilder.java @@ -31,7 +31,7 @@ /** * A builder for creating a new instance of the QueryClient type. */ -@ServiceClientBuilder(serviceClients = { QueryClient.class }) +@ServiceClientBuilder(serviceClients = { ConstantClient.class, SpecialCharClient.class }) public final class QueryClientBuilder implements HttpTrait, ProxyTrait, ConfigurationTrait, EndpointTrait { @Metadata(properties = { MetadataProperties.GENERATED }) @@ -223,13 +223,24 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of QueryClient class. + * Builds an instance of ConstantClient class. * - * @return an instance of QueryClient. + * @return an instance of ConstantClient. */ @Metadata(properties = { MetadataProperties.GENERATED }) - public QueryClient buildQueryClient() { + public ConstantClient buildConstantClient() { QueryClientImpl innerClient = buildInnerClient(); - return new QueryClient(innerClient.getConstants(), innerClient.getInstrumentation()); + return new ConstantClient(innerClient.getConstants(), innerClient.getInstrumentation()); + } + + /** + * Builds an instance of SpecialCharClient class. + * + * @return an instance of SpecialCharClient. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public SpecialCharClient buildSpecialCharClient() { + QueryClientImpl innerClient = buildInnerClient(); + return new SpecialCharClient(innerClient.getSpecialChars(), innerClient.getInstrumentation()); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java new file mode 100644 index 00000000000..453716449f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/SpecialCharClient.java @@ -0,0 +1,66 @@ +package parameters.query; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceClient; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.instrumentation.Instrumentation; +import parameters.query.implementation.SpecialCharsImpl; + +/** + * Initializes a new instance of the synchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class) +public final class SpecialCharClient { + @Metadata(properties = { MetadataProperties.GENERATED }) + private final SpecialCharsImpl serviceClient; + + private final Instrumentation instrumentation; + + /** + * Initializes an instance of SpecialCharClient class. + * + * @param serviceClient the service client implementation. + * @param instrumentation the instrumentation instance. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + SpecialCharClient(SpecialCharsImpl serviceClient, Instrumentation instrumentation) { + this.serviceClient = serviceClient; + this.instrumentation = instrumentation; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.Query.SpecialChar.dollarSign", requestContext, + updatedContext -> this.serviceClient.dollarSignWithResponse(filter, updatedContext)); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void dollarSign(String filter) { + dollarSignWithResponse(filter, RequestContext.none()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java index 77bdb99a195..1b2e14c2e55 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/QueryClientImpl.java @@ -63,6 +63,20 @@ public ConstantsImpl getConstants() { return this.constants; } + /** + * The SpecialCharsImpl object to access its operations. + */ + private final SpecialCharsImpl specialChars; + + /** + * Gets the SpecialCharsImpl object to access its operations. + * + * @return the SpecialCharsImpl object. + */ + public SpecialCharsImpl getSpecialChars() { + return this.specialChars; + } + /** * Initializes an instance of QueryClient client. * @@ -75,5 +89,6 @@ public QueryClientImpl(HttpPipeline httpPipeline, Instrumentation instrumentatio this.instrumentation = instrumentation; this.endpoint = endpoint; this.constants = new ConstantsImpl(this); + this.specialChars = new SpecialCharsImpl(this); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java new file mode 100644 index 00000000000..59303f3f77c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java @@ -0,0 +1,92 @@ +package parameters.query.implementation; + +import io.clientcore.core.annotations.ReturnType; +import io.clientcore.core.annotations.ServiceInterface; +import io.clientcore.core.annotations.ServiceMethod; +import io.clientcore.core.http.annotations.HostParam; +import io.clientcore.core.http.annotations.HttpRequestInformation; +import io.clientcore.core.http.annotations.QueryParam; +import io.clientcore.core.http.annotations.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.HttpResponseException; +import io.clientcore.core.http.models.RequestContext; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.instrumentation.Instrumentation; +import java.lang.reflect.InvocationTargetException; + +/** + * An instance of this class provides access to all the operations defined in SpecialChars. + */ +public final class SpecialCharsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpecialCharsService service; + + /** + * The service client containing this operation class. + */ + private final QueryClientImpl client; + + /** + * The instance of instrumentation to report telemetry. + */ + private final Instrumentation instrumentation; + + /** + * Initializes an instance of SpecialCharsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpecialCharsImpl(QueryClientImpl client) { + this.service = SpecialCharsService.getNewInstance(client.getHttpPipeline()); + this.client = client; + this.instrumentation = client.getInstrumentation(); + } + + /** + * The interface defining all the services for QueryClientSpecialChars to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "QueryClientSpecialChars", host = "{endpoint}") + public interface SpecialCharsService { + static SpecialCharsService getNewInstance(HttpPipeline pipeline) { + try { + Class clazz = Class.forName("parameters.query.implementation.SpecialCharsServiceImpl"); + return (SpecialCharsService) clazz.getMethod("getNewInstance", HttpPipeline.class) + .invoke(null, pipeline); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/query/special-char/dollarSign", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response dollarSign(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestContext requestContext); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse("Parameters.Query.SpecialChar.dollarSign", requestContext, + updatedContext -> { + return service.dollarSign(this.client.getEndpoint(), filter, updatedContext); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java new file mode 100644 index 00000000000..e6bef5368d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Fish.java @@ -0,0 +1,102 @@ +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotations.Metadata; +import io.clientcore.core.annotations.MetadataProperties; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * A discriminated model with no defined subtypes. The discriminator is declared but no models extend it. + */ +@Metadata(properties = { MetadataProperties.IMMUTABLE }) +public final class Fish implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private String kind = "Fish"; + + /* + * The size property. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + private final int size; + + /** + * Creates an instance of Fish class. + * + * @param size the size value to set. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public Fish(int size) { + this.size = size; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public String getKind() { + return this.kind; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public int getSize() { + return this.size; + } + + /** + * {@inheritDoc} + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Fish from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Fish if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Fish. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + public static Fish fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(size); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java index 1d11f3a38ab..7ac8ce82995 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -247,4 +247,66 @@ public Response getLegacyModelWithResponse(RequestContext requestConte public Dinosaur getLegacyModel() { return getLegacyModelWithResponse(RequestContext.none()).getValue(); } + + /** + * The getNoSubtypesModel operation. + * + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", requestContext, + updatedContext -> this.serviceClient.getNoSubtypesModelWithResponse(updatedContext)); + } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getNoSubtypesModel() { + return getNoSubtypesModelWithResponse(RequestContext.none()).getValue(); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(Fish input, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", requestContext, + updatedContext -> this.serviceClient.putNoSubtypesModelWithResponse(input, updatedContext)); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(properties = { MetadataProperties.GENERATED }) + @ServiceMethod(returns = ReturnType.SINGLE) + public void putNoSubtypesModel(Fish input) { + putNoSubtypesModelWithResponse(input, RequestContext.none()); + } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java index 96a1bcb7d1e..e83deee5158 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import type.model.inheritance.singlediscriminator.Bird; import type.model.inheritance.singlediscriminator.Dinosaur; +import type.model.inheritance.singlediscriminator.Fish; /** * Initializes a new instance of the SingleDiscriminatorClient type. @@ -158,6 +159,23 @@ Response getWrongDiscriminator(@HostParam("endpoint") String endpoint, @UnexpectedResponseExceptionDetail Response getLegacyModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestContext requestContext); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/no-subtypes/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNoSubtypesModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestContext requestContext); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/single-discriminator/no-subtypes/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") Fish input, + RequestContext requestContext); } /** @@ -291,4 +309,41 @@ public Response getLegacyModelWithResponse(RequestContext requestConte return service.getLegacyModel(this.getEndpoint(), accept, updatedContext); }); } + + /** + * The getNoSubtypesModel operation. + * + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel", requestContext, updatedContext -> { + final String accept = "application/json"; + return service.getNoSubtypesModel(this.getEndpoint(), accept, updatedContext); + }); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @param requestContext The context to configure the HTTP request before HTTP client sends it. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(Fish input, RequestContext requestContext) { + return this.instrumentation.instrumentWithResponse( + "Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel", requestContext, updatedContext -> { + final String contentType = "application/json"; + return service.putNoSubtypesModel(this.getEndpoint(), contentType, input, updatedContext); + }); + } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json new file mode 100644 index 00000000000..d69c725b70b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json @@ -0,0 +1 @@ +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.BodyRoot","crossLanguageVersion":"1b93bc1e60f7","crossLanguageDefinitions":{"parameters.bodyroot.BodyRootClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootClientBuilder":"Parameters.BodyRoot","parameters.bodyroot.BodyRootModel":"Parameters.BodyRoot.BodyRootModel"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/bodyroot/BodyRootClient.java","src/main/java/parameters/bodyroot/BodyRootClientBuilder.java","src/main/java/parameters/bodyroot/BodyRootModel.java","src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java","src/main/java/parameters/bodyroot/implementation/package-info.java","src/main/java/parameters/bodyroot/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json index 0eece0cddea..d491ee294d3 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-query_metadata.json @@ -1 +1 @@ -{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"e2bfb58d3cc1","crossLanguageDefinitions":{"parameters.query.QueryClient":"Parameters.Query.Constant","parameters.query.QueryClientBuilder":"Parameters.Query"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/QueryClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"d221aa20c419","crossLanguageDefinitions":{"parameters.query.ConstantClient":"Parameters.Query.Constant","parameters.query.QueryClientBuilder":"Parameters.Query","parameters.query.SpecialCharClient":"Parameters.Query.SpecialChar"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/ConstantClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/SpecialCharClient.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/SpecialCharsImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json index 2bbf23e7b20..9857c4dc04c 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json @@ -1 +1 @@ -{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"301c4a3b5af0","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file +{"flavor":"generic","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"d008d2bf96fe","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.Fish":"Type.Model.Inheritance.SingleDiscriminator.Fish","type.model.inheritance.singlediscriminator.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/Fish.java","src/main/java/type/model/inheritance/singlediscriminator/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java index fbed3285da3..db7ec54729b 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java @@ -7,7 +7,7 @@ public class QueryTests { - private final QueryClient client = new QueryClientBuilder().buildQueryClient(); + private final ConstantClient client = new QueryClientBuilder().buildConstantClient(); @Test public void testConstant() { diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index 8549c21e66b..f92c6c8848c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -14,25 +14,25 @@ "dependencies": { "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", - "@typespec/http-specs": "0.1.0-alpha.37", - "@azure-tools/azure-http-specs": "0.1.0-alpha.41", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.8.1.tgz", + "@typespec/http-specs": "0.1.0-alpha.38", + "@azure-tools/azure-http-specs": "0.1.0-alpha.42", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.9.0.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { - "@typespec/compiler": "1.12.0", - "@typespec/http": "1.12.0", - "@typespec/rest": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/openapi": "1.12.0", - "@typespec/xml": "0.82.0", - "@typespec/events": "0.82.0", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-autorest": "0.68.0" + "@typespec/compiler": "1.13.0", + "@typespec/http": "1.13.0", + "@typespec/rest": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/openapi": "1.13.0", + "@typespec/xml": "0.83.0", + "@typespec/events": "0.83.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-autorest": "0.69.0" }, "private": true } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java index cc0e7a13895..18659a6b52b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java @@ -5,9 +5,11 @@ package azure.resourcemanager.commonproperties; import azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient; +import azure.resourcemanager.commonproperties.implementation.ArmResourceIdentifiersImpl; import azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder; import azure.resourcemanager.commonproperties.implementation.ErrorsImpl; import azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesImpl; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifiers; import azure.resourcemanager.commonproperties.models.Errors; import azure.resourcemanager.commonproperties.models.ManagedIdentities; import com.azure.core.credential.TokenCredential; @@ -47,6 +49,8 @@ public final class CommonPropertiesManager { private Errors errors; + private ArmResourceIdentifiers armResourceIdentifiers; + private final CommonPropertiesClient clientObject; private CommonPropertiesManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { @@ -286,6 +290,19 @@ public Errors errors() { return errors; } + /** + * Gets the resource collection API of ArmResourceIdentifiers. It manages ArmResourceIdentifierResource. + * + * @return Resource collection API of ArmResourceIdentifiers. + */ + public ArmResourceIdentifiers armResourceIdentifiers() { + if (this.armResourceIdentifiers == null) { + this.armResourceIdentifiers + = new ArmResourceIdentifiersImpl(clientObject.getArmResourceIdentifiers(), this); + } + return armResourceIdentifiers; + } + /** * Gets wrapped service client CommonPropertiesClient providing direct access to the underlying auto-generated API * implementation, based on Azure REST API. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java new file mode 100644 index 00000000000..47072b69f83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.fluent; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * An instance of this class provides access to all the operations defined in ArmResourceIdentifiersClient. + */ +public interface ArmResourceIdentifiersClient { + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ArmResourceIdentifierResourceInner getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName); + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrReplaceWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource, Context context); + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ArmResourceIdentifierResourceInner createOrReplace(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java index 89b218eb72d..0209b4d61af 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java @@ -59,4 +59,11 @@ public interface CommonPropertiesClient { * @return the ErrorsClient object. */ ErrorsClient getErrors(); + + /** + * Gets the ArmResourceIdentifiersClient object to access its operations. + * + * @return the ArmResourceIdentifiersClient object. + */ + ArmResourceIdentifiersClient getArmResourceIdentifiers(); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java new file mode 100644 index 00000000000..438da6b1ec3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.fluent.models; + +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class ArmResourceIdentifierResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private ArmResourceIdentifierResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ArmResourceIdentifierResourceInner class. + */ + public ArmResourceIdentifierResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ArmResourceIdentifierResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ArmResourceIdentifierResourceInner object itself. + */ + public ArmResourceIdentifierResourceInner withProperties(ArmResourceIdentifierResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public ArmResourceIdentifierResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ArmResourceIdentifierResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArmResourceIdentifierResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArmResourceIdentifierResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArmResourceIdentifierResourceInner. + */ + public static ArmResourceIdentifierResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ArmResourceIdentifierResourceInner deserializedArmResourceIdentifierResourceInner + = new ArmResourceIdentifierResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedArmResourceIdentifierResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.properties + = ArmResourceIdentifierResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedArmResourceIdentifierResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedArmResourceIdentifierResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java new file mode 100644 index 00000000000..5d51e499999 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class ArmResourceIdentifierResourceImpl + implements ArmResourceIdentifierResource, ArmResourceIdentifierResource.Definition { + private ArmResourceIdentifierResourceInner innerObject; + + private final azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager; + + ArmResourceIdentifierResourceImpl(ArmResourceIdentifierResourceInner innerObject, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public ArmResourceIdentifierResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public ArmResourceIdentifierResourceInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.commonproperties.CommonPropertiesManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String armResourceIdentifierResourceName; + + public ArmResourceIdentifierResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ArmResourceIdentifierResource create() { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public ArmResourceIdentifierResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, this.innerModel(), + context) + .getValue(); + return this; + } + + ArmResourceIdentifierResourceImpl(String name, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerObject = new ArmResourceIdentifierResourceInner(); + this.serviceManager = serviceManager; + this.armResourceIdentifierResourceName = name; + } + + public ArmResourceIdentifierResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + return this; + } + + public ArmResourceIdentifierResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getArmResourceIdentifiers() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context) + .getValue(); + return this; + } + + public ArmResourceIdentifierResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ArmResourceIdentifierResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ArmResourceIdentifierResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public ArmResourceIdentifierResourceImpl withProperties(ArmResourceIdentifierResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java new file mode 100644 index 00000000000..0ff805481b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java @@ -0,0 +1,260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ArmResourceIdentifiersClient. + */ +public final class ArmResourceIdentifiersClientImpl implements ArmResourceIdentifiersClient { + /** + * The proxy service used to perform REST calls. + */ + private final ArmResourceIdentifiersService service; + + /** + * The service client containing this operation class. + */ + private final CommonPropertiesClientImpl client; + + /** + * Initializes an instance of ArmResourceIdentifiersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ArmResourceIdentifiersClientImpl(CommonPropertiesClientImpl client) { + this.service = RestProxy.create(ArmResourceIdentifiersService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CommonPropertiesClientArmResourceIdentifiers to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CommonPropertiesClientArmResourceIdentifiers") + public interface ArmResourceIdentifiersService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ArmResourceIdentifierResourceInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/armResourceIdentifierResources/{armResourceIdentifierResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("armResourceIdentifierResourceName") String armResourceIdentifierResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ArmResourceIdentifierResourceInner resource, Context context); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String armResourceIdentifierResourceName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String armResourceIdentifierResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, armResourceIdentifierResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context) { + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, accept, context); + } + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ArmResourceIdentifierResourceInner getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName) { + return getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrReplaceWithResponseAsync( + String resourceGroupName, String armResourceIdentifierResourceName, + ArmResourceIdentifierResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrReplace(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, contentType, + accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrReplaceAsync(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource) { + return createOrReplaceWithResponseAsync(resourceGroupName, armResourceIdentifierResourceName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, armResourceIdentifierResourceName, contentType, accept, + resource, context); + } + + /** + * Create a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ArmResourceIdentifierResourceInner createOrReplace(String resourceGroupName, + String armResourceIdentifierResourceName, ArmResourceIdentifierResourceInner resource) { + return createOrReplaceWithResponse(resourceGroupName, armResourceIdentifierResourceName, resource, Context.NONE) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java new file mode 100644 index 00000000000..59779ecd66c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.implementation; + +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifiers; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class ArmResourceIdentifiersImpl implements ArmResourceIdentifiers { + private static final ClientLogger LOGGER = new ClientLogger(ArmResourceIdentifiersImpl.class); + + private final ArmResourceIdentifiersClient innerClient; + + private final azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager; + + public ArmResourceIdentifiersImpl(ArmResourceIdentifiersClient innerClient, + azure.resourcemanager.commonproperties.CommonPropertiesManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ArmResourceIdentifierResourceImpl(inner.getValue(), this.manager())); + } + + public ArmResourceIdentifierResource getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName) { + ArmResourceIdentifierResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, armResourceIdentifierResourceName); + if (inner != null) { + return new ArmResourceIdentifierResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ArmResourceIdentifierResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String armResourceIdentifierResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "armResourceIdentifierResources"); + if (armResourceIdentifierResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'armResourceIdentifierResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String armResourceIdentifierResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "armResourceIdentifierResources"); + if (armResourceIdentifierResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'armResourceIdentifierResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, armResourceIdentifierResourceName, context); + } + + private ArmResourceIdentifiersClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.commonproperties.CommonPropertiesManager manager() { + return this.serviceManager; + } + + public ArmResourceIdentifierResourceImpl define(String name) { + return new ArmResourceIdentifierResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java index 0c015e90c3f..bf67d5c1129 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java @@ -4,6 +4,7 @@ package azure.resourcemanager.commonproperties.implementation; +import azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient; import azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient; import azure.resourcemanager.commonproperties.fluent.ErrorsClient; import azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient; @@ -155,6 +156,20 @@ public ErrorsClient getErrors() { return this.errors; } + /** + * The ArmResourceIdentifiersClient object to access its operations. + */ + private final ArmResourceIdentifiersClient armResourceIdentifiers; + + /** + * Gets the ArmResourceIdentifiersClient object to access its operations. + * + * @return the ArmResourceIdentifiersClient object. + */ + public ArmResourceIdentifiersClient getArmResourceIdentifiers() { + return this.armResourceIdentifiers; + } + /** * Initializes an instance of CommonPropertiesClient client. * @@ -175,6 +190,7 @@ public ErrorsClient getErrors() { this.apiVersion = "2023-12-01-preview"; this.managedIdentities = new ManagedIdentitiesClientImpl(this); this.errors = new ErrorsClientImpl(this); + this.armResourceIdentifiers = new ArmResourceIdentifiersClientImpl(this); } /** diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java new file mode 100644 index 00000000000..8fe53caee64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of ArmResourceIdentifierResource. + */ +public interface ArmResourceIdentifierResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + ArmResourceIdentifierResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner object. + * + * @return the inner object. + */ + ArmResourceIdentifierResourceInner innerModel(); + + /** + * The entirety of the ArmResourceIdentifierResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ArmResourceIdentifierResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ArmResourceIdentifierResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the ArmResourceIdentifierResource definition which contains all the minimum required properties + * for the resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + ArmResourceIdentifierResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ArmResourceIdentifierResource create(Context context); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the ArmResourceIdentifierResource definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(ArmResourceIdentifierResourceProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ArmResourceIdentifierResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ArmResourceIdentifierResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java new file mode 100644 index 00000000000..85435639270 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * ArmResourceIdentifier Resource Properties. + */ +@Fluent +public final class ArmResourceIdentifierResourceProperties + implements JsonSerializable { + /* + * The status of the last operation. + */ + private ResourceProvisioningState provisioningState; + + /* + * A basic ARM resource identifier without type or scopes. + */ + private String simpleArmId; + + /* + * An ARM resource identifier with type only. + */ + private String armIdWithType; + + /* + * An ARM resource identifier with type and scopes. + */ + private String armIdWithTypeAndScope; + + /* + * An ARM resource identifier with all scopes. + */ + private String armIdWithAllScopes; + + /** + * Creates an instance of ArmResourceIdentifierResourceProperties class. + */ + public ArmResourceIdentifierResourceProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the simpleArmId property: A basic ARM resource identifier without type or scopes. + * + * @return the simpleArmId value. + */ + public String simpleArmId() { + return this.simpleArmId; + } + + /** + * Set the simpleArmId property: A basic ARM resource identifier without type or scopes. + * + * @param simpleArmId the simpleArmId value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withSimpleArmId(String simpleArmId) { + this.simpleArmId = simpleArmId; + return this; + } + + /** + * Get the armIdWithType property: An ARM resource identifier with type only. + * + * @return the armIdWithType value. + */ + public String armIdWithType() { + return this.armIdWithType; + } + + /** + * Set the armIdWithType property: An ARM resource identifier with type only. + * + * @param armIdWithType the armIdWithType value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithType(String armIdWithType) { + this.armIdWithType = armIdWithType; + return this; + } + + /** + * Get the armIdWithTypeAndScope property: An ARM resource identifier with type and scopes. + * + * @return the armIdWithTypeAndScope value. + */ + public String armIdWithTypeAndScope() { + return this.armIdWithTypeAndScope; + } + + /** + * Set the armIdWithTypeAndScope property: An ARM resource identifier with type and scopes. + * + * @param armIdWithTypeAndScope the armIdWithTypeAndScope value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithTypeAndScope(String armIdWithTypeAndScope) { + this.armIdWithTypeAndScope = armIdWithTypeAndScope; + return this; + } + + /** + * Get the armIdWithAllScopes property: An ARM resource identifier with all scopes. + * + * @return the armIdWithAllScopes value. + */ + public String armIdWithAllScopes() { + return this.armIdWithAllScopes; + } + + /** + * Set the armIdWithAllScopes property: An ARM resource identifier with all scopes. + * + * @param armIdWithAllScopes the armIdWithAllScopes value to set. + * @return the ArmResourceIdentifierResourceProperties object itself. + */ + public ArmResourceIdentifierResourceProperties withArmIdWithAllScopes(String armIdWithAllScopes) { + this.armIdWithAllScopes = armIdWithAllScopes; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("simpleArmId", this.simpleArmId); + jsonWriter.writeStringField("armIdWithType", this.armIdWithType); + jsonWriter.writeStringField("armIdWithTypeAndScope", this.armIdWithTypeAndScope); + jsonWriter.writeStringField("armIdWithAllScopes", this.armIdWithAllScopes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArmResourceIdentifierResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArmResourceIdentifierResourceProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ArmResourceIdentifierResourceProperties. + */ + public static ArmResourceIdentifierResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ArmResourceIdentifierResourceProperties deserializedArmResourceIdentifierResourceProperties + = new ArmResourceIdentifierResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("simpleArmId".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.simpleArmId = reader.getString(); + } else if ("armIdWithType".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithType = reader.getString(); + } else if ("armIdWithTypeAndScope".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithTypeAndScope = reader.getString(); + } else if ("armIdWithAllScopes".equals(fieldName)) { + deserializedArmResourceIdentifierResourceProperties.armIdWithAllScopes = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedArmResourceIdentifierResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java new file mode 100644 index 00000000000..cbf3f717717 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ArmResourceIdentifiers. + */ +public interface ArmResourceIdentifiers { + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String armResourceIdentifierResourceName, Context context); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param armResourceIdentifierResourceName arm resource name for path. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource. + */ + ArmResourceIdentifierResource getByResourceGroup(String resourceGroupName, + String armResourceIdentifierResourceName); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + ArmResourceIdentifierResource getById(String id); + + /** + * Get a ArmResourceIdentifierResource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ArmResourceIdentifierResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ArmResourceIdentifierResource resource. + * + * @param name resource name. + * @return the first stage of the new ArmResourceIdentifierResource definition. + */ + ArmResourceIdentifierResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java new file mode 100644 index 00000000000..40f4a38dd60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.commonproperties.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java new file mode 100644 index 00000000000..6c91d0e4eb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupClient; +import azure.resourcemanager.managementgroup.implementation.ManagementGroupChildResourcesImpl; +import azure.resourcemanager.managementgroup.implementation.ManagementGroupClientBuilder; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResources; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to ManagementGroupManager. + * Arm Resource Provider management API. + */ +public final class ManagementGroupManager { + private ManagementGroupChildResources managementGroupChildResources; + + private final ManagementGroupClient clientObject; + + private ManagementGroupManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ManagementGroupClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public static ManagementGroupManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public static ManagementGroupManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ManagementGroupManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ManagementGroupManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ManagementGroupManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-managementgroup-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of ManagementGroup service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ManagementGroup service API instance. + */ + public ManagementGroupManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("azure.resourcemanager.managementgroup") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ManagementGroupManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of ManagementGroupChildResources. + * + * @return Resource collection API of ManagementGroupChildResources. + */ + public ManagementGroupChildResources managementGroupChildResources() { + if (this.managementGroupChildResources == null) { + this.managementGroupChildResources + = new ManagementGroupChildResourcesImpl(clientObject.getManagementGroupChildResources(), this); + } + return managementGroupChildResources; + } + + /** + * Gets wrapped service client ManagementGroupClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ManagementGroupClient. + */ + public ManagementGroupClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java new file mode 100644 index 00000000000..ac559a3162c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in ManagementGroupChildResourcesClient. + */ +public interface ManagementGroupChildResourcesClient { + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context); + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner get(String managementGroupId, String managementGroupChildResourceName); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagementGroupChildResourceInner> beginCreateOrUpdate( + String managementGroupId, String managementGroupChildResourceName, ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagementGroupChildResourceInner> beginCreateOrUpdate( + String managementGroupId, String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, + Context context); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagementGroupChildResourceInner update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String managementGroupId, String managementGroupChildResourceName); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByManagementGroup(String managementGroupId); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByManagementGroup(String managementGroupId, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java new file mode 100644 index 00000000000..e60ba06577a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ManagementGroupClient class. + */ +public interface ManagementGroupClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the ManagementGroupChildResourcesClient object to access its operations. + * + * @return the ManagementGroupChildResourcesClient object. + */ + ManagementGroupChildResourcesClient getManagementGroupChildResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java new file mode 100644 index 00000000000..b87789de563 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.fluent.models; + +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Concrete extension resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class ManagementGroupChildResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private ManagementGroupChildResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ManagementGroupChildResourceInner class. + */ + public ManagementGroupChildResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ManagementGroupChildResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ManagementGroupChildResourceInner object itself. + */ + public ManagementGroupChildResourceInner withProperties(ManagementGroupChildResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceInner. + */ + public static ManagementGroupChildResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceInner deserializedManagementGroupChildResourceInner + = new ManagementGroupChildResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.properties + = ManagementGroupChildResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedManagementGroupChildResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java new file mode 100644 index 00000000000..7bc5661857f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java new file mode 100644 index 00000000000..47cc28858f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java new file mode 100644 index 00000000000..8bcda8f0e70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import com.azure.core.management.SystemData; + +public final class ManagementGroupChildResourceImpl implements ManagementGroupChildResource { + private ManagementGroupChildResourceInner innerObject; + + private final azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager; + + ManagementGroupChildResourceImpl(ManagementGroupChildResourceInner innerObject, + azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public ManagementGroupChildResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ManagementGroupChildResourceInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.managementgroup.ManagementGroupManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java new file mode 100644 index 00000000000..4dc96f94473 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java @@ -0,0 +1,758 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.implementation.models.ManagementGroupChildResourceListResult; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ManagementGroupChildResourcesClient. + */ +public final class ManagementGroupChildResourcesClientImpl implements ManagementGroupChildResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ManagementGroupChildResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ManagementGroupClientImpl client; + + /** + * Initializes an instance of ManagementGroupChildResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ManagementGroupChildResourcesClientImpl(ManagementGroupClientImpl client) { + this.service = RestProxy.create(ManagementGroupChildResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ManagementGroupClientManagementGroupChildResources to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ManagementGroupClientManagementGroupChildResources") + public interface ManagementGroupChildResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner resource, Context context); + + @Put("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner resource, Context context); + + @Patch("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner properties, Context context); + + @Patch("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response updateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagementGroupChildResourceInner properties, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources/{managementGroupChildResourceName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, + @PathParam("managementGroupChildResourceName") String managementGroupChildResourceName, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByManagementGroup( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.ManagementGroupChild/managementGroupChildResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByManagementGroupSync( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("managementGroupId") String managementGroupId, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByManagementGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByManagementGroupNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String managementGroupId, + String managementGroupChildResourceName) { + return getWithResponseAsync(managementGroupId, managementGroupChildResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, accept, context); + } + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner get(String managementGroupId, String managementGroupChildResourceName) { + return getWithResponse(managementGroupId, managementGroupChildResourceName, Context.NONE).getValue(); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, resource, Context.NONE); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, resource, context); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ManagementGroupChildResourceInner> + beginCreateOrUpdateAsync(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(managementGroupId, managementGroupChildResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), ManagementGroupChildResourceInner.class, + ManagementGroupChildResourceInner.class, this.client.getContext()); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagementGroupChildResourceInner> + beginCreateOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource) { + Response response + = createOrUpdateWithResponse(managementGroupId, managementGroupChildResourceName, resource); + return this.client.getLroResult(response, + ManagementGroupChildResourceInner.class, ManagementGroupChildResourceInner.class, Context.NONE); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete extension resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagementGroupChildResourceInner> + beginCreateOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context) { + Response response + = createOrUpdateWithResponse(managementGroupId, managementGroupChildResourceName, resource, context); + return this.client.getLroResult(response, + ManagementGroupChildResourceInner.class, ManagementGroupChildResourceInner.class, context); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + return beginCreateOrUpdateAsync(managementGroupId, managementGroupChildResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + return beginCreateOrUpdate(managementGroupId, managementGroupChildResourceName, resource).getFinalResult(); + } + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + return beginCreateOrUpdate(managementGroupId, managementGroupChildResourceName, resource, context) + .getFinalResult(); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties) { + return updateWithResponseAsync(managementGroupId, managementGroupChildResourceName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, contentType, accept, properties, context); + } + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagementGroupChildResourceInner update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties) { + return updateWithResponse(managementGroupId, managementGroupChildResourceName, properties, Context.NONE) + .getValue(); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String managementGroupId, + String managementGroupChildResourceName) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + managementGroupId, managementGroupChildResourceName, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String managementGroupId, String managementGroupChildResourceName) { + return deleteWithResponseAsync(managementGroupId, managementGroupChildResourceName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context) { + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, + managementGroupChildResourceName, context); + } + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String managementGroupId, String managementGroupChildResourceName) { + deleteWithResponse(managementGroupId, managementGroupChildResourceName, Context.NONE); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByManagementGroupSinglePageAsync(String managementGroupId) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByManagementGroup(this.client.getEndpoint(), + this.client.getApiVersion(), managementGroupId, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByManagementGroupAsync(String managementGroupId) { + return new PagedFlux<>(() -> listByManagementGroupSinglePageAsync(managementGroupId), + nextLink -> listByManagementGroupNextSinglePageAsync(nextLink)); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupSinglePage(String managementGroupId) { + final String accept = "application/json"; + Response res = service.listByManagementGroupSync( + this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupSinglePage(String managementGroupId, + Context context) { + final String accept = "application/json"; + Response res = service.listByManagementGroupSync( + this.client.getEndpoint(), this.client.getApiVersion(), managementGroupId, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByManagementGroup(String managementGroupId) { + return new PagedIterable<>(() -> listByManagementGroupSinglePage(managementGroupId), + nextLink -> listByManagementGroupNextSinglePage(nextLink)); + } + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByManagementGroup(String managementGroupId, + Context context) { + return new PagedIterable<>(() -> listByManagementGroupSinglePage(managementGroupId, context), + nextLink -> listByManagementGroupNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByManagementGroupNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByManagementGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByManagementGroupNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByManagementGroupNextSinglePage(String nextLink, + Context context) { + final String accept = "application/json"; + Response res + = service.listByManagementGroupNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java new file mode 100644 index 00000000000..1b38a9f706c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResources; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class ManagementGroupChildResourcesImpl implements ManagementGroupChildResources { + private static final ClientLogger LOGGER = new ClientLogger(ManagementGroupChildResourcesImpl.class); + + private final ManagementGroupChildResourcesClient innerClient; + + private final azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager; + + public ManagementGroupChildResourcesImpl(ManagementGroupChildResourcesClient innerClient, + azure.resourcemanager.managementgroup.ManagementGroupManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + Response inner + = this.serviceClient().getWithResponse(managementGroupId, managementGroupChildResourceName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ManagementGroupChildResourceImpl(inner.getValue(), this.manager())); + } + + public ManagementGroupChildResource get(String managementGroupId, String managementGroupChildResourceName) { + ManagementGroupChildResourceInner inner + = this.serviceClient().get(managementGroupId, managementGroupChildResourceName); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ManagementGroupChildResource createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource) { + ManagementGroupChildResourceInner inner + = this.serviceClient().createOrUpdate(managementGroupId, managementGroupChildResourceName, resource); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ManagementGroupChildResource createOrUpdate(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner resource, Context context) { + ManagementGroupChildResourceInner inner = this.serviceClient() + .createOrUpdate(managementGroupId, managementGroupChildResourceName, resource, context); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context) { + Response inner = this.serviceClient() + .updateWithResponse(managementGroupId, managementGroupChildResourceName, properties, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ManagementGroupChildResourceImpl(inner.getValue(), this.manager())); + } + + public ManagementGroupChildResource update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties) { + ManagementGroupChildResourceInner inner + = this.serviceClient().update(managementGroupId, managementGroupChildResourceName, properties); + if (inner != null) { + return new ManagementGroupChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context) { + return this.serviceClient().deleteWithResponse(managementGroupId, managementGroupChildResourceName, context); + } + + public void deleteByResourceGroup(String managementGroupId, String managementGroupChildResourceName) { + this.serviceClient().delete(managementGroupId, managementGroupChildResourceName); + } + + public PagedIterable listByManagementGroup(String managementGroupId) { + PagedIterable inner + = this.serviceClient().listByManagementGroup(managementGroupId); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ManagementGroupChildResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByManagementGroup(String managementGroupId, + Context context) { + PagedIterable inner + = this.serviceClient().listByManagementGroup(managementGroupId, context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ManagementGroupChildResourceImpl(inner1, this.manager())); + } + + private ManagementGroupChildResourcesClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.managementgroup.ManagementGroupManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java new file mode 100644 index 00000000000..9a5147e1909 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the ManagementGroupClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ManagementGroupClientImpl.class }) +public final class ManagementGroupClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the ManagementGroupClientBuilder. + */ + public ManagementGroupClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ManagementGroupClientImpl with the provided parameters. + * + * @return an instance of ManagementGroupClientImpl. + */ + public ManagementGroupClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + ManagementGroupClientImpl client = new ManagementGroupClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java new file mode 100644 index 00000000000..839fee59369 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient; +import azure.resourcemanager.managementgroup.fluent.ManagementGroupClient; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ManagementGroupClientImpl type. + */ +@ServiceClient(builder = ManagementGroupClientBuilder.class) +public final class ManagementGroupClientImpl implements ManagementGroupClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The ManagementGroupChildResourcesClient object to access its operations. + */ + private final ManagementGroupChildResourcesClient managementGroupChildResources; + + /** + * Gets the ManagementGroupChildResourcesClient object to access its operations. + * + * @return the ManagementGroupChildResourcesClient object. + */ + public ManagementGroupChildResourcesClient getManagementGroupChildResources() { + return this.managementGroupChildResources; + } + + /** + * Initializes an instance of ManagementGroupClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + */ + ManagementGroupClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2023-12-01-preview"; + this.managementGroupChildResources = new ManagementGroupChildResourcesClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagementGroupClientImpl.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java new file mode 100644 index 00000000000..1734d5cff5b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java new file mode 100644 index 00000000000..7aa4fba8867 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.implementation.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The response of a ManagementGroupChildResource list operation. + */ +@Immutable +public final class ManagementGroupChildResourceListResult + implements JsonSerializable { + /* + * The ManagementGroupChildResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of ManagementGroupChildResourceListResult class. + */ + private ManagementGroupChildResourceListResult() { + } + + /** + * Get the value property: The ManagementGroupChildResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceListResult if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceListResult. + */ + public static ManagementGroupChildResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceListResult deserializedManagementGroupChildResourceListResult + = new ManagementGroupChildResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ManagementGroupChildResourceInner.fromJson(reader1)); + deserializedManagementGroupChildResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedManagementGroupChildResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceListResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java new file mode 100644 index 00000000000..764c7e548c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java new file mode 100644 index 00000000000..ce62d50d58e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.management.SystemData; + +/** + * An immutable client-side representation of ManagementGroupChildResource. + */ +public interface ManagementGroupChildResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + ManagementGroupChildResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner object. + * + * @return the inner object. + */ + ManagementGroupChildResourceInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java new file mode 100644 index 00000000000..a2cea68fedf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * ManagementGroupChildResource properties. + */ +@Fluent +public final class ManagementGroupChildResourceProperties + implements JsonSerializable { + /* + * The description of the resource. + */ + private String description; + + /* + * The status of the last operation. + */ + private ProvisioningState provisioningState; + + /** + * Creates an instance of ManagementGroupChildResourceProperties class. + */ + public ManagementGroupChildResourceProperties() { + } + + /** + * Get the description property: The description of the resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the resource. + * + * @param description the description value to set. + * @return the ManagementGroupChildResourceProperties object itself. + */ + public ManagementGroupChildResourceProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagementGroupChildResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagementGroupChildResourceProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ManagementGroupChildResourceProperties. + */ + public static ManagementGroupChildResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagementGroupChildResourceProperties deserializedManagementGroupChildResourceProperties + = new ManagementGroupChildResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedManagementGroupChildResourceProperties.description = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedManagementGroupChildResourceProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedManagementGroupChildResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java new file mode 100644 index 00000000000..6af24b87f65 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ManagementGroupChildResources. + */ +public interface ManagementGroupChildResources { + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource along with {@link Response}. + */ + Response getWithResponse(String managementGroupId, + String managementGroupChildResourceName, Context context); + + /** + * Get a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a ManagementGroupChildResource. + */ + ManagementGroupChildResource get(String managementGroupId, String managementGroupChildResourceName); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource); + + /** + * Create a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource createOrUpdate(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner resource, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type + * along with {@link Response}. + */ + Response updateWithResponse(String managementGroupId, + String managementGroupChildResourceName, ManagementGroupChildResourceInner properties, Context context); + + /** + * Update a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete extension resource types can be created by aliasing this type using a specific property type. + */ + ManagementGroupChildResource update(String managementGroupId, String managementGroupChildResourceName, + ManagementGroupChildResourceInner properties); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String managementGroupId, String managementGroupChildResourceName, + Context context); + + /** + * Delete a ManagementGroupChildResource. + * + * @param managementGroupId The management group ID. + * @param managementGroupChildResourceName The name of the ManagementGroupChildResource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String managementGroupId, String managementGroupChildResourceName); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByManagementGroup(String managementGroupId); + + /** + * List ManagementGroupChildResource resources by scope. + * + * @param managementGroupId The management group ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ManagementGroupChildResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByManagementGroup(String managementGroupId, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java new file mode 100644 index 00000000000..879ae78b6d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.managementgroup.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ProvisioningState. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Static value Provisioning for ProvisioningState. + */ + public static final ProvisioningState PROVISIONING = fromString("Provisioning"); + + /** + * Static value Updating for ProvisioningState. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * Static value Deleting for ProvisioningState. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * Static value Accepted for ProvisioningState. + */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java new file mode 100644 index 00000000000..ea12c2867d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java new file mode 100644 index 00000000000..ed4ca36ee66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/azure/resourcemanager/managementgroup/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ManagementGroup. + * Arm Resource Provider management API. + */ +package azure.resourcemanager.managementgroup; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java new file mode 100644 index 00000000000..473ea7fc80f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootAsyncClient.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import parameters.bodyroot.implementation.BodyRootClientImpl; +import parameters.bodyroot.models.BodyRootModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class, isAsync = true) +public final class BodyRootAsyncClient { + @Generated + private final BodyRootClientImpl serviceClient; + + /** + * Initializes an instance of BodyRootAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyRootAsyncClient(BodyRootClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + return this.serviceClient.nestedWithResponseAsync(bodyRootParameters, requestOptions); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono nested(BodyRootModel bodyRootParameters) { + // Generated convenience method for nestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return nestedWithResponse(BinaryData.fromObject(bodyRootParameters), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java new file mode 100644 index 00000000000..70be9e5e742 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClient.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import parameters.bodyroot.implementation.BodyRootClientImpl; +import parameters.bodyroot.models.BodyRootModel; + +/** + * Initializes a new instance of the synchronous BodyRootClient type. + */ +@ServiceClient(builder = BodyRootClientBuilder.class) +public final class BodyRootClient { + @Generated + private final BodyRootClientImpl serviceClient; + + /** + * Initializes an instance of BodyRootClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyRootClient(BodyRootClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + return this.serviceClient.nestedWithResponse(bodyRootParameters, requestOptions); + } + + /** + * The nested operation. + * + * @param bodyRootParameters The bodyRootParameters parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void nested(BodyRootModel bodyRootParameters) { + // Generated convenience method for nestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + nestedWithResponse(BinaryData.fromObject(bodyRootParameters), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java new file mode 100644 index 00000000000..e59f9ed5acd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/BodyRootClientBuilder.java @@ -0,0 +1,287 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import parameters.bodyroot.implementation.BodyRootClientImpl; + +/** + * A builder for creating a new instance of the BodyRootClient type. + */ +@ServiceClientBuilder(serviceClients = { BodyRootClient.class, BodyRootAsyncClient.class }) +public final class BodyRootClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("parameters-bodyroot.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BodyRootClientBuilder. + */ + @Generated + public BodyRootClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyRootClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the BodyRootClientBuilder. + */ + @Generated + public BodyRootClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BodyRootClientImpl with the provided parameters. + * + * @return an instance of BodyRootClientImpl. + */ + @Generated + private BodyRootClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BodyRootClientImpl client + = new BodyRootClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of BodyRootAsyncClient class. + * + * @return an instance of BodyRootAsyncClient. + */ + @Generated + public BodyRootAsyncClient buildAsyncClient() { + return new BodyRootAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of BodyRootClient class. + * + * @return an instance of BodyRootClient. + */ + @Generated + public BodyRootClient buildClient() { + return new BodyRootClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BodyRootClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java new file mode 100644 index 00000000000..6ace16374d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the BodyRootClient type. + */ +public final class BodyRootClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyRootClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param endpoint Service host. + */ + public BodyRootClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyRootClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Service host. + */ + public BodyRootClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(BodyRootClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for BodyRootClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BodyRootClient") + public interface BodyRootClientService { + @Post("/parameters/body-root/nested") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> nested(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData bodyRootParameters, RequestOptions requestOptions, + Context context); + + @Post("/parameters/body-root/nested") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response nestedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData bodyRootParameters, RequestOptions requestOptions, + Context context); + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> nestedWithResponseAsync(BinaryData bodyRootParameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.nested(this.getEndpoint(), contentType, bodyRootParameters, requestOptions, context)); + } + + /** + * The nested operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     category: String (Optional)
+     *     linkType: String (Optional)
+     *     wasSuccessful: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + * @param bodyRootParameters The bodyRootParameters parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response nestedWithResponse(BinaryData bodyRootParameters, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.nestedSync(this.getEndpoint(), contentType, bodyRootParameters, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java new file mode 100644 index 00000000000..2141462a093 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the implementations for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java new file mode 100644 index 00000000000..12265da15c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/BodyRootModel.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The BodyRootModel model. + */ +@Fluent +public final class BodyRootModel implements JsonSerializable { + /* + * The category property. + */ + @Generated + private String category; + + /* + * The linkType property. + */ + @Generated + private String linkType; + + /* + * The wasSuccessful property. + */ + @Generated + private Boolean wasSuccessful; + + /** + * Creates an instance of BodyRootModel class. + */ + @Generated + public BodyRootModel() { + } + + /** + * Get the category property: The category property. + * + * @return the category value. + */ + @Generated + public String getCategory() { + return this.category; + } + + /** + * Set the category property: The category property. + * + * @param category the category value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setCategory(String category) { + this.category = category; + return this; + } + + /** + * Get the linkType property: The linkType property. + * + * @return the linkType value. + */ + @Generated + public String getLinkType() { + return this.linkType; + } + + /** + * Set the linkType property: The linkType property. + * + * @param linkType the linkType value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setLinkType(String linkType) { + this.linkType = linkType; + return this; + } + + /** + * Get the wasSuccessful property: The wasSuccessful property. + * + * @return the wasSuccessful value. + */ + @Generated + public Boolean isWasSuccessful() { + return this.wasSuccessful; + } + + /** + * Set the wasSuccessful property: The wasSuccessful property. + * + * @param wasSuccessful the wasSuccessful value to set. + * @return the BodyRootModel object itself. + */ + @Generated + public BodyRootModel setWasSuccessful(Boolean wasSuccessful) { + this.wasSuccessful = wasSuccessful; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("category", this.category); + jsonWriter.writeStringField("linkType", this.linkType); + jsonWriter.writeBooleanField("wasSuccessful", this.wasSuccessful); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyRootModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyRootModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BodyRootModel. + */ + @Generated + public static BodyRootModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BodyRootModel deserializedBodyRootModel = new BodyRootModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("category".equals(fieldName)) { + deserializedBodyRootModel.category = reader.getString(); + } else if ("linkType".equals(fieldName)) { + deserializedBodyRootModel.linkType = reader.getString(); + } else if ("wasSuccessful".equals(fieldName)) { + deserializedBodyRootModel.wasSuccessful = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedBodyRootModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java new file mode 100644 index 00000000000..9bfbfdc8a63 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/models/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the data models for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java new file mode 100644 index 00000000000..40a4d5626da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/bodyroot/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * + * Package containing the classes for BodyRoot. + * Test for @bodyRoot parameter patterns. + * + */ +package parameters.bodyroot; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java similarity index 95% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java index d3eaac1971e..ed03f457327 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantAsyncClient.java @@ -22,17 +22,17 @@ * Initializes a new instance of the asynchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class, isAsync = true) -public final class QueryAsyncClient { +public final class ConstantAsyncClient { @Generated private final ConstantsImpl serviceClient; /** - * Initializes an instance of QueryAsyncClient class. + * Initializes an instance of ConstantAsyncClient class. * * @param serviceClient the service client implementation. */ @Generated - QueryAsyncClient(ConstantsImpl serviceClient) { + ConstantAsyncClient(ConstantsImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java similarity index 95% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java index b27e52ec51e..fe781ddfa67 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/ConstantClient.java @@ -20,17 +20,17 @@ * Initializes a new instance of the synchronous QueryClient type. */ @ServiceClient(builder = QueryClientBuilder.class) -public final class QueryClient { +public final class ConstantClient { @Generated private final ConstantsImpl serviceClient; /** - * Initializes an instance of QueryClient class. + * Initializes an instance of ConstantClient class. * * @param serviceClient the service client implementation. */ @Generated - QueryClient(ConstantsImpl serviceClient) { + ConstantClient(ConstantsImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java index 49e65770444..2f5f89c4acf 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/QueryClientBuilder.java @@ -40,7 +40,12 @@ /** * A builder for creating a new instance of the QueryClient type. */ -@ServiceClientBuilder(serviceClients = { QueryClient.class, QueryAsyncClient.class }) +@ServiceClientBuilder( + serviceClients = { + ConstantClient.class, + SpecialCharClient.class, + ConstantAsyncClient.class, + SpecialCharAsyncClient.class }) public final class QueryClientBuilder implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated @@ -264,23 +269,43 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of QueryAsyncClient class. + * Builds an instance of ConstantAsyncClient class. * - * @return an instance of QueryAsyncClient. + * @return an instance of ConstantAsyncClient. */ @Generated - public QueryAsyncClient buildAsyncClient() { - return new QueryAsyncClient(buildInnerClient().getConstants()); + public ConstantAsyncClient buildConstantAsyncClient() { + return new ConstantAsyncClient(buildInnerClient().getConstants()); } /** - * Builds an instance of QueryClient class. + * Builds an instance of SpecialCharAsyncClient class. * - * @return an instance of QueryClient. + * @return an instance of SpecialCharAsyncClient. */ @Generated - public QueryClient buildClient() { - return new QueryClient(buildInnerClient().getConstants()); + public SpecialCharAsyncClient buildSpecialCharAsyncClient() { + return new SpecialCharAsyncClient(buildInnerClient().getSpecialChars()); + } + + /** + * Builds an instance of ConstantClient class. + * + * @return an instance of ConstantClient. + */ + @Generated + public ConstantClient buildConstantClient() { + return new ConstantClient(buildInnerClient().getConstants()); + } + + /** + * Builds an instance of SpecialCharClient class. + * + * @return an instance of SpecialCharClient. + */ + @Generated + public SpecialCharClient buildSpecialCharClient() { + return new SpecialCharClient(buildInnerClient().getSpecialChars()); } private static final ClientLogger LOGGER = new ClientLogger(QueryClientBuilder.class); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java new file mode 100644 index 00000000000..b4756be4677 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharAsyncClient.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.FluxUtil; +import parameters.query.implementation.SpecialCharsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class, isAsync = true) +public final class SpecialCharAsyncClient { + @Generated + private final SpecialCharsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharAsyncClient(SpecialCharsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return this.serviceClient.dollarSignWithResponseAsync(filter, requestOptions); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono dollarSign(String filter) { + // Generated convenience method for dollarSignWithResponse + RequestOptions requestOptions = new RequestOptions(); + return dollarSignWithResponse(filter, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java new file mode 100644 index 00000000000..557211a5c0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/SpecialCharClient.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import parameters.query.implementation.SpecialCharsImpl; + +/** + * Initializes a new instance of the synchronous QueryClient type. + */ +@ServiceClient(builder = QueryClientBuilder.class) +public final class SpecialCharClient { + @Generated + private final SpecialCharsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharClient(SpecialCharsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return this.serviceClient.dollarSignWithResponse(filter, requestOptions); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void dollarSign(String filter) { + // Generated convenience method for dollarSignWithResponse + RequestOptions requestOptions = new RequestOptions(); + dollarSignWithResponse(filter, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java index 1a7823bfd4d..87888470a27 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/QueryClientImpl.java @@ -71,6 +71,20 @@ public ConstantsImpl getConstants() { return this.constants; } + /** + * The SpecialCharsImpl object to access its operations. + */ + private final SpecialCharsImpl specialChars; + + /** + * Gets the SpecialCharsImpl object to access its operations. + * + * @return the SpecialCharsImpl object. + */ + public SpecialCharsImpl getSpecialChars() { + return this.specialChars; + } + /** * Initializes an instance of QueryClient client. * @@ -103,5 +117,6 @@ public QueryClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAd this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; this.constants = new ConstantsImpl(this); + this.specialChars = new SpecialCharsImpl(this); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java new file mode 100644 index 00000000000..c3f1289ed2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/parameters/query/implementation/SpecialCharsImpl.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.query.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SpecialChars. + */ +public final class SpecialCharsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpecialCharsService service; + + /** + * The service client containing this operation class. + */ + private final QueryClientImpl client; + + /** + * Initializes an instance of SpecialCharsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpecialCharsImpl(QueryClientImpl client) { + this.service + = RestProxy.create(SpecialCharsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for QueryClientSpecialChars to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "QueryClientSpecialChars") + public interface SpecialCharsService { + @Get("/parameters/query/special-char/dollarSign") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> dollarSign(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestOptions requestOptions, Context context); + + @Get("/parameters/query/special-char/dollarSign") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response dollarSignSync(@HostParam("endpoint") String endpoint, @QueryParam("$filter") String filter, + RequestOptions requestOptions, Context context); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> dollarSignWithResponseAsync(String filter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.dollarSign(this.client.getEndpoint(), filter, requestOptions, context)); + } + + /** + * The dollarSign operation. + * + * @param filter The filter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response dollarSignWithResponse(String filter, RequestOptions requestOptions) { + return service.dollarSignSync(this.client.getEndpoint(), filter, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java index 770d0e65de8..d5b74270f0f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java @@ -20,6 +20,7 @@ import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Dinosaur; +import type.model.inheritance.singlediscriminator.models.Fish; /** * Initializes a new instance of the asynchronous SingleDiscriminatorClient type. @@ -228,6 +229,60 @@ public Mono> getLegacyModelWithResponse(RequestOptions requ return this.serviceClient.getLegacyModelWithResponseAsync(requestOptions); } + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesModelWithResponseAsync(requestOptions); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putNoSubtypesModelWithResponseAsync(input, requestOptions); + } + /** * The getModel operation. * @@ -366,4 +421,43 @@ public Mono getLegacyModel() { return getLegacyModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(Dinosaur.class)); } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNoSubtypesModel() { + // Generated convenience method for getNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putNoSubtypesModel(Fish input) { + // Generated convenience method for putNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNoSubtypesModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java index 004c639ff53..ec98358efa0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -18,6 +18,7 @@ import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Dinosaur; +import type.model.inheritance.singlediscriminator.models.Fish; /** * Initializes a new instance of the synchronous SingleDiscriminatorClient type. @@ -225,6 +226,59 @@ public Response getLegacyModelWithResponse(RequestOptions requestOpt return this.serviceClient.getLegacyModelWithResponse(requestOptions); } + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesModelWithResponse(requestOptions); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putNoSubtypesModelWithResponse(input, requestOptions); + } + /** * The getModel operation. * @@ -352,4 +406,41 @@ public Dinosaur getLegacyModel() { RequestOptions requestOptions = new RequestOptions(); return getLegacyModelWithResponse(requestOptions).getValue().toObject(Dinosaur.class); } + + /** + * The getNoSubtypesModel operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discriminated model with no defined subtypes. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getNoSubtypesModel() { + // Generated convenience method for getNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putNoSubtypesModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void putNoSubtypesModel(Fish input) { + // Generated convenience method for putNoSubtypesModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putNoSubtypesModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java index 59e696cf8e9..eb42cfeb8c5 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -256,6 +256,44 @@ Mono> getLegacyModel(@HostParam("endpoint") String endpoint @UnexpectedResponseExceptionType(HttpResponseException.class) Response getLegacyModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNoSubtypesModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putNoSubtypesModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/no-subtypes/model") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putNoSubtypesModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); } /** @@ -640,4 +678,113 @@ public Response getLegacyModelWithResponse(RequestOptions requestOpt final String accept = "application/json"; return service.getLegacyModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } + + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNoSubtypesModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getNoSubtypesModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a discriminated model with no defined subtypes along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNoSubtypesModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNoSubtypesModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putNoSubtypesModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putNoSubtypesModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNoSubtypesModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putNoSubtypesModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java new file mode 100644 index 00000000000..0dd3d145dcf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A discriminated model with no defined subtypes. The discriminator is declared but no models extend it. + */ +@Immutable +public final class Fish implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private String kind = "Fish"; + + /* + * The size property. + */ + @Generated + private final int size; + + /** + * Creates an instance of Fish class. + * + * @param size the size value to set. + */ + @Generated + public Fish(int size) { + this.size = size; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public int getSize() { + return this.size; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Fish from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Fish if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Fish. + */ + @Generated + public static Fish fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(size); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json index 0fdaa16cc0e..c94b2877527 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-commonproperties-generated_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.CommonProperties":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.CommonProperties","crossLanguageVersion":"ad207ac2ccc3","crossLanguageDefinitions":{"azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.fluent.ErrorsClient":"Azure.ResourceManager.CommonProperties.Error","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedError":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedErrorWithResponse":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient":"Azure.ResourceManager.CommonProperties.ManagedIdentity","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.models.ConfidentialResourceInner":"Azure.ResourceManager.CommonProperties.ConfidentialResource","azure.resourcemanager.commonproperties.fluent.models.ManagedIdentityTrackedResourceInner":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource","azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.models.ApiError":"Azure.ResourceManager.CommonProperties.CloudError","azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties":"Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties","azure.resourcemanager.commonproperties.models.InnerError":"Azure.ResourceManager.CommonProperties.InnerError","azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties","azure.resourcemanager.commonproperties.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","azure.resourcemanager.commonproperties.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity"},"generatedFiles":["src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java","src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ErrorsClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ManagedIdentitiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ConfidentialResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ManagedIdentityTrackedResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/fluent/package-info.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientBuilder.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ConfidentialResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentityTrackedResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/commonproperties/implementation/package-info.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiError.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiErrorException.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/Errors.java","src/main/java/azure/resourcemanager/commonproperties/models/InnerError.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentities.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentityType.java","src/main/java/azure/resourcemanager/commonproperties/models/UserAssignedIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.CommonProperties":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.CommonProperties","crossLanguageVersion":"f9b539c8f6ce","crossLanguageDefinitions":{"azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.createOrReplace":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.createOrReplace","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.createOrReplaceWithResponse":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.createOrReplace","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.get","azure.resourcemanager.commonproperties.fluent.ArmResourceIdentifiersClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifiers.get","azure.resourcemanager.commonproperties.fluent.CommonPropertiesClient":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.fluent.ErrorsClient":"Azure.ResourceManager.CommonProperties.Error","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedError":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.createForUserDefinedErrorWithResponse":"Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ErrorsClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.Error.getForPredefinedError","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient":"Azure.ResourceManager.CommonProperties.ManagedIdentity","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.createWithSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroup":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.get","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssigned":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.ManagedIdentitiesClient.updateWithUserAssignedAndSystemAssignedWithResponse":"Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned","azure.resourcemanager.commonproperties.fluent.models.ArmResourceIdentifierResourceInner":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifierResource","azure.resourcemanager.commonproperties.fluent.models.ConfidentialResourceInner":"Azure.ResourceManager.CommonProperties.ConfidentialResource","azure.resourcemanager.commonproperties.fluent.models.ManagedIdentityTrackedResourceInner":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource","azure.resourcemanager.commonproperties.implementation.CommonPropertiesClientBuilder":"Azure.ResourceManager.CommonProperties","azure.resourcemanager.commonproperties.models.ApiError":"Azure.ResourceManager.CommonProperties.CloudError","azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties":"Azure.ResourceManager.CommonProperties.ArmResourceIdentifierResourceProperties","azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties":"Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties","azure.resourcemanager.commonproperties.models.InnerError":"Azure.ResourceManager.CommonProperties.InnerError","azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties":"Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties","azure.resourcemanager.commonproperties.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","azure.resourcemanager.commonproperties.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","azure.resourcemanager.commonproperties.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity"},"generatedFiles":["src/main/java/azure/resourcemanager/commonproperties/CommonPropertiesManager.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ArmResourceIdentifiersClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/CommonPropertiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ErrorsClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/ManagedIdentitiesClient.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ArmResourceIdentifierResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ConfidentialResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/ManagedIdentityTrackedResourceInner.java","src/main/java/azure/resourcemanager/commonproperties/fluent/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/fluent/package-info.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifierResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ArmResourceIdentifiersImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientBuilder.java","src/main/java/azure/resourcemanager/commonproperties/implementation/CommonPropertiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ConfidentialResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ErrorsImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesClientImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentitiesImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ManagedIdentityTrackedResourceImpl.java","src/main/java/azure/resourcemanager/commonproperties/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/commonproperties/implementation/package-info.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiError.java","src/main/java/azure/resourcemanager/commonproperties/models/ApiErrorException.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifierResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ArmResourceIdentifiers.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ConfidentialResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/Errors.java","src/main/java/azure/resourcemanager/commonproperties/models/InnerError.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentities.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResource.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedIdentityTrackedResourceProperties.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/ManagedServiceIdentityType.java","src/main/java/azure/resourcemanager/commonproperties/models/ResourceProvisioningState.java","src/main/java/azure/resourcemanager/commonproperties/models/UserAssignedIdentity.java","src/main/java/azure/resourcemanager/commonproperties/models/package-info.java","src/main/java/azure/resourcemanager/commonproperties/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json new file mode 100644 index 00000000000..30e65e9c296 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-managementgroup-generated_metadata.json @@ -0,0 +1 @@ +{"flavor":"Azure","apiVersions":{"Azure.ResourceManager.ManagementGroup":"2023-12-01-preview"},"crossLanguagePackageId":"Azure.ResourceManager.ManagementGroup","crossLanguageVersion":"f15d0d496982","crossLanguageDefinitions":{"azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.beginCreateOrUpdate":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.createOrUpdate","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.createOrUpdate":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.createOrUpdate","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.delete":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.delete","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.deleteWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.delete","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.get":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.get","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.getWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.get","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.listByManagementGroup":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.listByManagementGroup","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.update":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.update","azure.resourcemanager.managementgroup.fluent.ManagementGroupChildResourcesClient.updateWithResponse":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResources.update","azure.resourcemanager.managementgroup.fluent.ManagementGroupClient":"Azure.ResourceManager.ManagementGroup","azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResource","azure.resourcemanager.managementgroup.implementation.ManagementGroupClientBuilder":"Azure.ResourceManager.ManagementGroup","azure.resourcemanager.managementgroup.implementation.models.ManagementGroupChildResourceListResult":"Azure.ResourceManager.ResourceListResult","azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties":"Azure.ResourceManager.ManagementGroup.ManagementGroupChildResourceProperties","azure.resourcemanager.managementgroup.models.ProvisioningState":"Azure.ResourceManager.ManagementGroup.ProvisioningState"},"generatedFiles":["src/main/java/azure/resourcemanager/managementgroup/ManagementGroupManager.java","src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupChildResourcesClient.java","src/main/java/azure/resourcemanager/managementgroup/fluent/ManagementGroupClient.java","src/main/java/azure/resourcemanager/managementgroup/fluent/models/ManagementGroupChildResourceInner.java","src/main/java/azure/resourcemanager/managementgroup/fluent/models/package-info.java","src/main/java/azure/resourcemanager/managementgroup/fluent/package-info.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourceImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesClientImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupChildResourcesImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientBuilder.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ManagementGroupClientImpl.java","src/main/java/azure/resourcemanager/managementgroup/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/managementgroup/implementation/models/ManagementGroupChildResourceListResult.java","src/main/java/azure/resourcemanager/managementgroup/implementation/package-info.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResource.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResourceProperties.java","src/main/java/azure/resourcemanager/managementgroup/models/ManagementGroupChildResources.java","src/main/java/azure/resourcemanager/managementgroup/models/ProvisioningState.java","src/main/java/azure/resourcemanager/managementgroup/models/package-info.java","src/main/java/azure/resourcemanager/managementgroup/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json index cdd07e3847c..9d7165df93d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-commonproperties-generated/proxy-config.json @@ -1 +1 @@ -[["azure.resourcemanager.commonproperties.implementation.ErrorsClientImpl$ErrorsService"],["azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesClientImpl$ManagedIdentitiesService"]] \ No newline at end of file +[["azure.resourcemanager.commonproperties.implementation.ArmResourceIdentifiersClientImpl$ArmResourceIdentifiersService"],["azure.resourcemanager.commonproperties.implementation.ErrorsClientImpl$ErrorsService"],["azure.resourcemanager.commonproperties.implementation.ManagedIdentitiesClientImpl$ManagedIdentitiesService"]] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json new file mode 100644 index 00000000000..ee2057bbcba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/proxy-config.json @@ -0,0 +1 @@ +[["azure.resourcemanager.managementgroup.implementation.ManagementGroupChildResourcesClientImpl$ManagementGroupChildResourcesService"]] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-managementgroup-generated/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json new file mode 100644 index 00000000000..2048222e2a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyroot_metadata.json @@ -0,0 +1 @@ +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.BodyRoot","crossLanguageVersion":"1b93bc1e60f7","crossLanguageDefinitions":{"parameters.bodyroot.BodyRootAsyncClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootAsyncClient.nested":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootAsyncClient.nestedWithResponse":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClient":"Parameters.BodyRoot","parameters.bodyroot.BodyRootClient.nested":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClient.nestedWithResponse":"Parameters.BodyRoot.nested","parameters.bodyroot.BodyRootClientBuilder":"Parameters.BodyRoot","parameters.bodyroot.models.BodyRootModel":"Parameters.BodyRoot.BodyRootModel"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/bodyroot/BodyRootAsyncClient.java","src/main/java/parameters/bodyroot/BodyRootClient.java","src/main/java/parameters/bodyroot/BodyRootClientBuilder.java","src/main/java/parameters/bodyroot/implementation/BodyRootClientImpl.java","src/main/java/parameters/bodyroot/implementation/package-info.java","src/main/java/parameters/bodyroot/models/BodyRootModel.java","src/main/java/parameters/bodyroot/models/package-info.java","src/main/java/parameters/bodyroot/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json index ecff4386b60..d2540b329d8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-query_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"e2bfb58d3cc1","crossLanguageDefinitions":{"parameters.query.QueryAsyncClient":"Parameters.Query.Constant","parameters.query.QueryAsyncClient.post":"Parameters.Query.Constant.post","parameters.query.QueryAsyncClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClient":"Parameters.Query.Constant","parameters.query.QueryClient.post":"Parameters.Query.Constant.post","parameters.query.QueryClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClientBuilder":"Parameters.Query"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/QueryAsyncClient.java","src/main/java/parameters/query/QueryClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Parameters.Query","crossLanguageVersion":"d221aa20c419","crossLanguageDefinitions":{"parameters.query.ConstantAsyncClient":"Parameters.Query.Constant","parameters.query.ConstantAsyncClient.post":"Parameters.Query.Constant.post","parameters.query.ConstantAsyncClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.ConstantClient":"Parameters.Query.Constant","parameters.query.ConstantClient.post":"Parameters.Query.Constant.post","parameters.query.ConstantClient.postWithResponse":"Parameters.Query.Constant.post","parameters.query.QueryClientBuilder":"Parameters.Query","parameters.query.SpecialCharAsyncClient":"Parameters.Query.SpecialChar","parameters.query.SpecialCharAsyncClient.dollarSign":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharAsyncClient.dollarSignWithResponse":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharClient":"Parameters.Query.SpecialChar","parameters.query.SpecialCharClient.dollarSign":"Parameters.Query.SpecialChar.dollarSign","parameters.query.SpecialCharClient.dollarSignWithResponse":"Parameters.Query.SpecialChar.dollarSign"},"generatedFiles":["src/main/java/module-info.java","src/main/java/parameters/query/ConstantAsyncClient.java","src/main/java/parameters/query/ConstantClient.java","src/main/java/parameters/query/QueryClientBuilder.java","src/main/java/parameters/query/SpecialCharAsyncClient.java","src/main/java/parameters/query/SpecialCharClient.java","src/main/java/parameters/query/implementation/ConstantsImpl.java","src/main/java/parameters/query/implementation/QueryClientImpl.java","src/main/java/parameters/query/implementation/SpecialCharsImpl.java","src/main/java/parameters/query/implementation/package-info.java","src/main/java/parameters/query/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json index a66af8cc696..9709b7e59e0 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"301c4a3b5af0","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.models.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.models.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.models.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.models.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.models.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.models.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.models.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/models/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/models/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/models/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/models/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/models/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/models/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/models/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/models/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{},"crossLanguagePackageId":"Type.Model.Inheritance.SingleDiscriminator","crossLanguageVersion":"d008d2bf96fe","crossLanguageDefinitions":{"type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getLegacyModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse":"Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putNoSubtypesModel":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putNoSubtypesModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putNoSubtypesModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse":"Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel","type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder":"Type.Model.Inheritance.SingleDiscriminator","type.model.inheritance.singlediscriminator.models.Bird":"Type.Model.Inheritance.SingleDiscriminator.Bird","type.model.inheritance.singlediscriminator.models.Dinosaur":"Type.Model.Inheritance.SingleDiscriminator.Dinosaur","type.model.inheritance.singlediscriminator.models.Eagle":"Type.Model.Inheritance.SingleDiscriminator.Eagle","type.model.inheritance.singlediscriminator.models.Fish":"Type.Model.Inheritance.SingleDiscriminator.Fish","type.model.inheritance.singlediscriminator.models.Goose":"Type.Model.Inheritance.SingleDiscriminator.Goose","type.model.inheritance.singlediscriminator.models.SeaGull":"Type.Model.Inheritance.SingleDiscriminator.SeaGull","type.model.inheritance.singlediscriminator.models.Sparrow":"Type.Model.Inheritance.SingleDiscriminator.Sparrow","type.model.inheritance.singlediscriminator.models.TRex":"Type.Model.Inheritance.SingleDiscriminator.TRex"},"generatedFiles":["src/main/java/module-info.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java","src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java","src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/models/Bird.java","src/main/java/type/model/inheritance/singlediscriminator/models/Dinosaur.java","src/main/java/type/model/inheritance/singlediscriminator/models/Eagle.java","src/main/java/type/model/inheritance/singlediscriminator/models/Fish.java","src/main/java/type/model/inheritance/singlediscriminator/models/Goose.java","src/main/java/type/model/inheritance/singlediscriminator/models/SeaGull.java","src/main/java/type/model/inheritance/singlediscriminator/models/Sparrow.java","src/main/java/type/model/inheritance/singlediscriminator/models/TRex.java","src/main/java/type/model/inheritance/singlediscriminator/models/package-info.java","src/main/java/type/model/inheritance/singlediscriminator/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties new file mode 100644 index 00000000000..defbd48204e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-managementgroup-generated.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties new file mode 100644 index 00000000000..ca812989b4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyroot.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java new file mode 100644 index 00000000000..935e88983c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/generated/BodyRootClientTestBase.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyroot.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.util.Configuration; +import parameters.bodyroot.BodyRootClient; +import parameters.bodyroot.BodyRootClientBuilder; + +class BodyRootClientTestBase extends TestProxyTestBase { + protected BodyRootClient bodyRootClient; + + @Override + protected void beforeTest() { + BodyRootClientBuilder bodyRootClientbuilder = new BodyRootClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + bodyRootClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bodyRootClient = bodyRootClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java index 34823dfd15d..db7ec54729b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java @@ -7,7 +7,7 @@ public class QueryTests { - private final QueryClient client = new QueryClientBuilder().buildClient(); + private final ConstantClient client = new QueryClientBuilder().buildConstantClient(); @Test public void testConstant() { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java index a44b9453f61..b16439abbc9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/generated/QueryClientTestBase.java @@ -13,22 +13,34 @@ import com.azure.core.test.TestMode; import com.azure.core.test.TestProxyTestBase; import com.azure.core.util.Configuration; -import parameters.query.QueryClient; +import parameters.query.ConstantClient; import parameters.query.QueryClientBuilder; +import parameters.query.SpecialCharClient; class QueryClientTestBase extends TestProxyTestBase { - protected QueryClient queryClient; + protected ConstantClient constantClient; + + protected SpecialCharClient specialCharClient; @Override protected void beforeTest() { - QueryClientBuilder queryClientbuilder = new QueryClientBuilder() + QueryClientBuilder constantClientbuilder = new QueryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + constantClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + constantClient = constantClientbuilder.buildConstantClient(); + + QueryClientBuilder specialCharClientbuilder = new QueryClientBuilder() .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); if (getTestMode() == TestMode.RECORD) { - queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + specialCharClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); } - queryClient = queryClientbuilder.buildClient(); + specialCharClient = specialCharClientbuilder.buildSpecialCharClient(); } } diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index 95538252fb7..58b51c2a3db 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -14,26 +14,26 @@ "lodash": "~4.18.1" }, "devDependencies": { - "@azure-tools/typespec-autorest": "0.68.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-azure-rulesets": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", + "@azure-tools/typespec-autorest": "0.69.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-azure-rulesets": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.58.8", "@microsoft/api-extractor-model": "^7.33.8", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.24", "@types/node": "~25.9.2", - "@typespec/compiler": "1.12.0", - "@typespec/events": "0.82.0", - "@typespec/http": "1.12.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/events": "0.83.0", + "@typespec/http": "1.13.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "~11.0.0", @@ -45,19 +45,19 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.0 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" } }, "node_modules/@autorest/codemodel": { @@ -134,24 +134,24 @@ } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.68.0.tgz", - "integrity": "sha512-ywcB68x0jOuplKg1u9ZpjOamHbIEEgAaMuXTP72cvWXE7q1eGLCN1DQx1Uk5ME8VLJKAX6cMOMHK4hcmg9tvuw==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.69.0.tgz", + "integrity": "sha512-6lOOe3NWfLI8M5NGLM1ZzIFRe34gVPj2GXzti9ag6o3fVpC6eMUfacv1sU4zmz9dkpKTdOUXNO5qm3DvqPRC8Q==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/xml": { @@ -160,24 +160,24 @@ } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.68.0.tgz", - "integrity": "sha512-p0qUkRZav5fdQvGe2gSCvlgsvpM0y9xVhgH2GpXi5ZzpYfNGzxd8oZr8VOCP8mjMVfGQ3AtnowbmrHALEZgz7Q==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.69.0.tgz", + "integrity": "sha512-UNdPb/DgMvXqwWk9hb54QOAumCJ6u6GGy+bj3RIIT1Sht6FR9rIn8AQ/UQ7WtrhbJBoqvQo5dxtS565a9/VRZw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/rest": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.68.0.tgz", - "integrity": "sha512-1zgXpOb/fGfB7SrFqawKasSOTIi9cZPWyK8V3RHyNWFZVQclEMGBzSvBHi6an4AEChqcjCSMh5MEr4BSujW4Ew==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.69.0.tgz", + "integrity": "sha512-q/kdsGhVpvn2wb3OedxFHg7hp+al3FynUAPsz2gwqJx62z6UGOEJhtYCWP3osatVgxvKRhhh8uYl5mHRMDFi3g==", "dev": true, "license": "MIT", "dependencies": { @@ -188,34 +188,34 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/versioning": "^0.83.0" } }, "node_modules/@azure-tools/typespec-azure-rulesets": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.68.0.tgz", - "integrity": "sha512-cXZ3jiDNqJgpBQLguNgXjvAsvYo7VwtlQxFMzTr96gpoAiuBViH+3eOhVd5HA4H96NgAWSddTMHXZJZzcsnE5A==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.69.0.tgz", + "integrity": "sha512-+7KThtfHupWBDSwDR9rRHNmBb15gxACH8iPOOohRr1J28Gu25YWlz1G00r62X9VUBFLZTxYc4rQ2QCxPFT0uFw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@azure-tools/typespec-azure-resource-manager": "^0.68.0", - "@azure-tools/typespec-client-generator-core": "^0.68.0", - "@typespec/compiler": "^1.12.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@azure-tools/typespec-azure-resource-manager": "^0.69.0", + "@azure-tools/typespec-client-generator-core": "^0.69.0", + "@typespec/compiler": "^1.13.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.4", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.4.tgz", - "integrity": "sha512-p32EXsrSC9giZUNdsQ2gmvDENFIEW2E0zto3FmjBZ3OeB5wCw1ZAZ+KnO0rsoKFovBvHSsQatNCKJvM/x89AgA==", + "version": "0.69.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.69.0.tgz", + "integrity": "sha512-ro8zzOeiN/74r0wM19R77gzLtbfjIFgKgr1Rusii/vhCfJIoVC7IcqLxhbJl0RVkjyhRFKt4GCRAw4iurnrDnw==", "dev": true, "license": "MIT", "dependencies": { @@ -227,16 +227,16 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/sse": "^0.82.0", - "@typespec/streams": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@azure-tools/typespec-azure-core": "^0.69.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": "^0.83.0", + "@typespec/sse": "^0.83.0", + "@typespec/streams": "^0.83.0", + "@typespec/versioning": "^0.83.0", + "@typespec/xml": "^0.83.0" } }, "node_modules/@azure/abort-controller": { @@ -1659,9 +1659,9 @@ "license": "MIT" }, "node_modules/@typespec/compiler": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.12.0.tgz", - "integrity": "sha512-hKCkHEEDdCpXFyOU8ln+TzBBwonFMbkeUV0zIc+vBETyO8p/Upui3XvEyLOyB4CpKUReHzGeGm3gcFjNc73ygg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.13.0.tgz", + "integrity": "sha512-DonoHiyAMx0UjSmssqTrFtya+v97wny1aHcTLU5QF2wFzLATtcwUU9hbPC+eXhepuTunMOCHf8yk3pEsH6PZYA==", "dev": true, "license": "MIT", "dependencies": { @@ -1819,30 +1819,30 @@ } }, "node_modules/@typespec/events": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.82.0.tgz", - "integrity": "sha512-4gxwWndMVmYF6e5ETrwW6b77h1DsSc2ZiIbNo98XePaynD6yz/ooHKKtNKacjC2gmWhfRz1ArPioYn0YHvQkxw==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.83.0.tgz", + "integrity": "sha512-3EP1EIjdLgwStgd2rGWaF/QqY7YRAt+DIYnnYG2VsdPwa8s2t6K6eJ9YJDXveeHImAkHs+cpFuwxnjKMl4hOyw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/http": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.12.0.tgz", - "integrity": "sha512-3Bb1M6VSuEVPWOecXj3h3I/ddMpb9cmKRQQq34oq7LatiK4fwVBp+EdWbqzEzaRUGHm9mZtqsMsxZf5FndT8dg==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.13.0.tgz", + "integrity": "sha512-tf8XFddU6g1MZSAVCLC/0Xa4fNfUO0CcHe6PWpmC3bvUojxMnpRcERI2DdoRJ+aycB9Q+Z8wN8bJO3up6u+sCw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/streams": "^0.83.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -1851,31 +1851,31 @@ } }, "node_modules/@typespec/openapi": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.12.0.tgz", - "integrity": "sha512-XtkCMPpzXFfuIzmx/BQrCMUCCk7d37lkqZe5ubJmvJ02Fr7yvAbofrgtNUZ1BbFe3TBBUS2nB3E3mjT3tE4zCQ==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.13.0.tgz", + "integrity": "sha512-omPc9n+LM2WvjYwnIf31RCxmG17fFUOVLBRsWg4T1mbcsNCj4grnNP7Lwt+irIZCiKtmLKxq3ViE7jYixCkZ3g==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/rest": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.82.0.tgz", - "integrity": "sha512-cKjKEd8lgE3EdU9b5xXLoSdKBcifITOhHS2n9LPbEG9w6APfWDWGdtUe4UKV3wxWq9HlT143wpECW7IjrPhjnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.83.0.tgz", + "integrity": "sha512-WMEwEe1kdaOdZ0c+ct5BVmTSBXkrPniUYDWCz3K52T4in2dNc7J6YGP6tL8bXgQz5B0CsP0VNO12N+UysQDsLw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0" + "@typespec/compiler": "^1.13.0", + "@typespec/http": "^1.13.0" } }, "node_modules/@typespec/spec-api": { @@ -2111,32 +2111,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.82.0.tgz", - "integrity": "sha512-4jBByfLsS7yQAIqmbLkfrw4XoPm9kOqawvW5gVXmKtnMMDYR0RmfBhsnAXBqhUXGbnFq0bDJGEw3GX+6k3mKnA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.83.0.tgz", + "integrity": "sha512-04WNaju2rwBbcF5pG+HrKQtdcrmSGuTVziLHNA9XOqj1qM7Uon3+wo2g+ZZ3Z6tngfqQoTCPyDcRHqZtGRdNuw==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/events": "^0.82.0", - "@typespec/http": "^1.12.0", - "@typespec/streams": "^0.82.0" + "@typespec/compiler": "^1.13.0", + "@typespec/events": "^0.83.0", + "@typespec/http": "^1.13.0", + "@typespec/streams": "^0.83.0" } }, "node_modules/@typespec/streams": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.82.0.tgz", - "integrity": "sha512-cr/6h6VV/6OJeG8RNcSd0SDes5iEXiuGUcKGrMN6wF8qKTTrY2hXNhfqCCn3lamDOg00wbi7ke+laz6pHWN3tg==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.83.0.tgz", + "integrity": "sha512-wbO6sdH1Uf+UwjxxsWdHQkjJ3wwiYsAKI+L66qnDYVXAFe02sUdMKd0mxH5o9ipGXE52MZ+yvZ52vHAD+g3RFQ==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -2155,29 +2155,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.82.0.tgz", - "integrity": "sha512-s8giuYQTQPniy2YxNfKXYpAU2Vm4L74TdOsbFWe0tG+jnOy/9tt7kKTH4QF1sB8nRvmjv8h31EoHtZYOPe1GvA==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.83.0.tgz", + "integrity": "sha512-nE66ta0ixpHB6FQpSzqnj8QnVfgFsxeK/4Xv+DxYx2nB/w18f6VjkF+hW+A/zs1tZIYvBZVbCNa/Rcr8zM6fhg==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@typespec/xml": { - "version": "0.82.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.82.0.tgz", - "integrity": "sha512-/Bwlt7HwSltojSbalkh7hGRh/lB5aMJllnb7gAAf3xRPMlnmu5VJqDFFcbZKqDvkwgGXZX/xHo458c4kott5Ug==", + "version": "0.83.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.83.0.tgz", + "integrity": "sha512-2/dtAD8jGPkIdwpQ1G1P+5+qdMPeafQiIKCd8NdAnOo0w9OZ59Io52jINm9HdN8+FcbOrqK8+B2N9rlPRj7PqA==", "dev": true, "license": "MIT", "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0" + "@typespec/compiler": "^1.13.0" } }, "node_modules/@vitest/coverage-v8": { diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index 1fb9c122bd6..01ea582a38c 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-java", - "version": "0.8.1", + "version": "0.9.0", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -49,19 +49,19 @@ "generator/http-client-generator/target/classes/PerfAutomation.jfc" ], "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.68.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.68.0 <1.0.0", - "@typespec/compiler": "^1.12.0", - "@typespec/events": ">=0.82.0 <1.0.0", - "@typespec/http": "^1.12.0", - "@typespec/openapi": "^1.12.0", - "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/sse": ">=0.82.0 <1.0.0", - "@typespec/streams": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/xml": ">=0.82.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.69.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.69.0 <1.0.0", + "@typespec/compiler": "^1.13.0", + "@typespec/events": ">=0.83.0 <1.0.0", + "@typespec/http": "^1.13.0", + "@typespec/openapi": "^1.13.0", + "@typespec/rest": ">=0.83.0 <1.0.0", + "@typespec/sse": ">=0.83.0 <1.0.0", + "@typespec/streams": ">=0.83.0 <1.0.0", + "@typespec/versioning": ">=0.83.0 <1.0.0", + "@typespec/xml": ">=0.83.0 <1.0.0" }, "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -69,26 +69,26 @@ "lodash": "~4.18.1" }, "devDependencies": { - "@azure-tools/typespec-autorest": "0.68.0", - "@azure-tools/typespec-azure-core": "0.68.0", - "@azure-tools/typespec-azure-resource-manager": "0.68.0", - "@azure-tools/typespec-azure-rulesets": "0.68.0", - "@azure-tools/typespec-client-generator-core": "0.68.4", + "@azure-tools/typespec-autorest": "0.69.0", + "@azure-tools/typespec-azure-core": "0.69.0", + "@azure-tools/typespec-azure-resource-manager": "0.69.0", + "@azure-tools/typespec-azure-rulesets": "0.69.0", + "@azure-tools/typespec-client-generator-core": "0.69.0", "@microsoft/api-extractor": "^7.58.8", "@microsoft/api-extractor-model": "^7.33.8", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.24", "@types/node": "~25.9.2", - "@typespec/compiler": "1.12.0", - "@typespec/events": "0.82.0", - "@typespec/http": "1.12.0", - "@typespec/openapi": "1.12.0", - "@typespec/rest": "0.82.0", + "@typespec/compiler": "1.13.0", + "@typespec/events": "0.83.0", + "@typespec/http": "1.13.0", + "@typespec/openapi": "1.13.0", + "@typespec/rest": "0.83.0", "@typespec/spector": "0.1.0-alpha.25", - "@typespec/sse": "0.82.0", - "@typespec/streams": "0.82.0", - "@typespec/versioning": "0.82.0", - "@typespec/xml": "0.82.0", + "@typespec/sse": "0.83.0", + "@typespec/streams": "0.83.0", + "@typespec/versioning": "0.83.0", + "@typespec/xml": "0.83.0", "@vitest/coverage-v8": "^4.1.8", "@vitest/ui": "^4.1.8", "c8": "~11.0.0", From b8e49edba2dfc5c34430aa3ac115e647f9b16ce0 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 14:24:56 +0800 Subject: [PATCH 11/29] Disable Java dollar-sign query tests pending http-specs release (#10961) `QueryTests.testDollarSign` is failing in Java because the fix lives in `@typespec/http-specs` and is not yet available through the released package consumed by the Java test projects. This PR keeps the Java branch releasable by removing the unreleased route workaround and temporarily disabling the affected tests. - **Problem** - The Java query tests exercise the `$filter` dollar-sign scenario against the published `@typespec/http-specs` package, which still contains the broken route. - Keeping the route fix in this branch would only patch local sources and generated code, not the package version Java actually consumes. - **Changes** - Reverted the temporary `http-specs` route and generated-path edits from this branch. - Added targeted `@Disabled` annotations to `QueryTests.testDollarSign` in both Java test suites: - `http-client-generator-test` - `http-client-generator-clientcore-test` - **Scope** - Leaves the rest of the query coverage intact. - Isolates the workaround to the two known failing tests until the `http-specs` fix is published and can be pulled into Java. - **Example** ```java @Test @Disabled("Blocked until @typespec/http-specs publishes the dollar-sign route fix") public void testDollarSign() { specialCharClient.dollarSign("status eq 'active'"); } ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> Co-authored-by: Weidong Xu --- ...ent-java-add-e2e-tests-2026-6-11-3-30-0.md | 7 ++ .../parameters/bodyroot/BodyRootTests.java | 16 ++++ .../java/parameters/query/QueryTests.java | 12 ++- .../inheritance/SingleDiscriminatorTest.java | 10 +++ .../CommonPropertiesTests.java | 41 +++++++++ .../managementgroup/ManagementGroupTests.java | 84 +++++++++++++++++++ .../parameters/bodyroot/BodyRootTests.java | 17 ++++ .../java/parameters/query/QueryTests.java | 12 ++- .../inheritance/SingleDiscriminatorTest.java | 10 +++ 9 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 .chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java diff --git a/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md b/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md new file mode 100644 index 00000000000..a9150ca5029 --- /dev/null +++ b/.chronus/changes/http-client-java-add-e2e-tests-2026-6-11-3-30-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-java" +--- + +Add e2e tests for parameters/body-root, parameters/query special char, type/model/inheritance/single-discriminator no-subtypes, azure/resourcemanager/common-properties arm-resource-identifiers, and azure/resourcemanager/management-group scenarios diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java new file mode 100644 index 00000000000..75cdcb9d9e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyroot/BodyRootTests.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.bodyroot; + +import org.junit.jupiter.api.Test; + +public class BodyRootTests { + + private final BodyRootClient client = new BodyRootClientBuilder().buildClient(); + + @Test + public void testNested() { + client.nested(new BodyRootModel().setCategory("widget").setLinkType("hard").setWasSuccessful(true)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java index db7ec54729b..8f512938876 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/query/QueryTests.java @@ -3,14 +3,22 @@ package parameters.query; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class QueryTests { - private final ConstantClient client = new QueryClientBuilder().buildConstantClient(); + private final ConstantClient constantClient = new QueryClientBuilder().buildConstantClient(); + private final SpecialCharClient specialCharClient = new QueryClientBuilder().buildSpecialCharClient(); @Test public void testConstant() { - client.post(); + constantClient.post(); + } + + @Test + @Disabled("Blocked until @typespec/http-specs publishes the dollar-sign route fix") + public void testDollarSign() { + specialCharClient.dollarSign("status eq 'active'"); } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java index 43453f622ab..65ad3d70d0f 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import type.model.inheritance.singlediscriminator.Bird; import type.model.inheritance.singlediscriminator.Eagle; +import type.model.inheritance.singlediscriminator.Fish; import type.model.inheritance.singlediscriminator.Goose; import type.model.inheritance.singlediscriminator.SeaGull; import type.model.inheritance.singlediscriminator.SingleDiscriminatorClient; @@ -36,4 +37,13 @@ public void testSingleDiscriminator() { Assertions.assertEquals(Sparrow.class, recursiveModel.getHate().get("key3").getClass()); client.putRecursiveModel(recursiveModel); } + + @Test + public void testNoSubtypesModel() { + Fish fish = client.getNoSubtypesModel(); + Assertions.assertNotNull(fish); + Assertions.assertEquals(10, fish.getSize()); + + client.putNoSubtypesModel(fish); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java index bb7878993ad..11cccea7fb1 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java @@ -4,11 +4,14 @@ package azure.resourcemanager.commonproperties; import azure.resourcemanager.commonproperties.models.ApiErrorException; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResource; +import azure.resourcemanager.commonproperties.models.ArmResourceIdentifierResourceProperties; import azure.resourcemanager.commonproperties.models.ConfidentialResourceProperties; import azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResource; import azure.resourcemanager.commonproperties.models.ManagedIdentityTrackedResourceProperties; import azure.resourcemanager.commonproperties.models.ManagedServiceIdentity; import azure.resourcemanager.commonproperties.models.ManagedServiceIdentityType; +import azure.resourcemanager.commonproperties.models.ResourceProvisioningState; import azure.resourcemanager.commonproperties.models.UserAssignedIdentity; import com.azure.core.management.Region; import com.azure.core.management.exception.ManagementException; @@ -91,4 +94,42 @@ public void testError() { Assertions.assertNotNull(exception); Assertions.assertEquals("ResourceNotFound", exception.getValue().getCode()); } + + @Test + public void testArmResourceIdentifiers() { + final String subscriptionId = "00000000-0000-0000-0000-000000000000"; + final String resourceGroup = "test-rg"; + final String simpleArmId = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup + + "/providers/Microsoft.Network/virtualNetworks/myVnet"; + final String armIdWithAllScopes = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup + + "/providers/Microsoft.Compute/virtualMachines/myVm"; + + // Create + ArmResourceIdentifierResource resource = manager.armResourceIdentifiers() + .define("armId") + .withRegion(Region.US_EAST) + .withExistingResourceGroup(resourceGroup) + .withProperties(new ArmResourceIdentifierResourceProperties().withSimpleArmId(simpleArmId) + .withArmIdWithType(simpleArmId) + .withArmIdWithTypeAndScope(simpleArmId) + .withArmIdWithAllScopes(armIdWithAllScopes)) + .create(); + Assertions.assertNotNull(resource); + Assertions.assertEquals("armId", resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(ResourceProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + Assertions.assertEquals(simpleArmId, resource.properties().simpleArmId()); + Assertions.assertEquals(simpleArmId, resource.properties().armIdWithType()); + Assertions.assertEquals(simpleArmId, resource.properties().armIdWithTypeAndScope()); + Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes()); + + // Get + resource = manager.armResourceIdentifiers().getByResourceGroup(resourceGroup, "armId"); + Assertions.assertNotNull(resource); + Assertions.assertEquals("armId", resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(ResourceProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + Assertions.assertEquals(simpleArmId, resource.properties().simpleArmId()); + Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes()); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java new file mode 100644 index 00000000000..0c5a0e6a8cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/resourcemanager/managementgroup/ManagementGroupTests.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azure.resourcemanager.managementgroup; + +import azure.resourcemanager.managementgroup.fluent.models.ManagementGroupChildResourceInner; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResource; +import azure.resourcemanager.managementgroup.models.ManagementGroupChildResourceProperties; +import azure.resourcemanager.managementgroup.models.ProvisioningState; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.ArmUtils; + +public class ManagementGroupTests { + + private static final String MANAGEMENT_GROUP_ID = "test-mg"; + private static final String RESOURCE_NAME = "resource"; + private static final String RESOURCE_TYPE = "Microsoft.ManagementGroupChild/managementGroupChildResources"; + private static final String RESOURCE_DESCRIPTION_VALID = "valid"; + private static final String RESOURCE_DESCRIPTION_VALID2 = "valid2"; + + private final ManagementGroupManager manager + = ManagementGroupManager.authenticate(ArmUtils.createTestHttpPipeline(), ArmUtils.getAzureProfile()); + + @Test + public void testGet() { + ManagementGroupChildResource resource + = manager.managementGroupChildResources().get(MANAGEMENT_GROUP_ID, RESOURCE_NAME); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testCreateOrUpdate() { + ManagementGroupChildResource resource = manager.managementGroupChildResources() + .createOrUpdate(MANAGEMENT_GROUP_ID, RESOURCE_NAME, new ManagementGroupChildResourceInner().withProperties( + new ManagementGroupChildResourceProperties().withDescription(RESOURCE_DESCRIPTION_VALID))); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testUpdate() { + ManagementGroupChildResource resource = manager.managementGroupChildResources() + .update(MANAGEMENT_GROUP_ID, RESOURCE_NAME, new ManagementGroupChildResourceInner().withProperties( + new ManagementGroupChildResourceProperties().withDescription(RESOURCE_DESCRIPTION_VALID2))); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID2, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } + + @Test + public void testDelete() { + manager.managementGroupChildResources().deleteByResourceGroup(MANAGEMENT_GROUP_ID, RESOURCE_NAME); + } + + @Test + public void testListByManagementGroup() { + List resources = manager.managementGroupChildResources() + .listByManagementGroup(MANAGEMENT_GROUP_ID) + .stream() + .collect(Collectors.toList()); + Assertions.assertEquals(1, resources.size()); + ManagementGroupChildResource resource = resources.get(0); + Assertions.assertNotNull(resource); + Assertions.assertEquals(RESOURCE_NAME, resource.name()); + Assertions.assertEquals(RESOURCE_TYPE, resource.type()); + Assertions.assertNotNull(resource.properties()); + Assertions.assertEquals(RESOURCE_DESCRIPTION_VALID, resource.properties().description()); + Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java new file mode 100644 index 00000000000..95087f9a002 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/bodyroot/BodyRootTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.bodyroot; + +import org.junit.jupiter.api.Test; +import parameters.bodyroot.models.BodyRootModel; + +public class BodyRootTests { + + private final BodyRootClient client = new BodyRootClientBuilder().buildClient(); + + @Test + public void testNested() { + client.nested(new BodyRootModel().setCategory("widget").setLinkType("hard").setWasSuccessful(true)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java index db7ec54729b..8f512938876 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/parameters/query/QueryTests.java @@ -3,14 +3,22 @@ package parameters.query; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class QueryTests { - private final ConstantClient client = new QueryClientBuilder().buildConstantClient(); + private final ConstantClient constantClient = new QueryClientBuilder().buildConstantClient(); + private final SpecialCharClient specialCharClient = new QueryClientBuilder().buildSpecialCharClient(); @Test public void testConstant() { - client.post(); + constantClient.post(); + } + + @Test + @Disabled("Blocked until @typespec/http-specs publishes the dollar-sign route fix") + public void testDollarSign() { + specialCharClient.dollarSign("status eq 'active'"); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java index 0aba3bf2f3d..552b4227335 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java @@ -9,6 +9,7 @@ import type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder; import type.model.inheritance.singlediscriminator.models.Bird; import type.model.inheritance.singlediscriminator.models.Eagle; +import type.model.inheritance.singlediscriminator.models.Fish; import type.model.inheritance.singlediscriminator.models.Goose; import type.model.inheritance.singlediscriminator.models.SeaGull; import type.model.inheritance.singlediscriminator.models.Sparrow; @@ -36,4 +37,13 @@ public void testSingleDiscriminator() { Assertions.assertEquals(Sparrow.class, recursiveModel.getHate().get("key3").getClass()); client.putRecursiveModel(recursiveModel); } + + @Test + public void testNoSubtypesModel() { + Fish fish = client.getNoSubtypesModel(); + Assertions.assertNotNull(fish); + Assertions.assertEquals(10, fish.getSize()); + + client.putNoSubtypesModel(fish); + } } From 5cbe6d948ca66320cc8a792a83c07d34ea7ef652 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:01:42 -0700 Subject: [PATCH 12/29] fix(http-client-csharp): bump pinned cop release to v2026.6.10.1 (#10959) Bumps the pinned Agent Cop release used by `eng/scripts/Invoke-Cop.ps1` from `v2026.6.9.1` to the latest release `v2026.6.10.1`. Verified locally against a clean `main` checkout: the new binary downloads, providers seed at the matching tag, and the `cop-checks/` rules run clean (`cop checks passed.`). --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/instructions/http-client-csharp.instructions.md | 1 + packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/instructions/http-client-csharp.instructions.md b/.github/instructions/http-client-csharp.instructions.md index 81e9a172f2b..a0eb8751fdc 100644 --- a/.github/instructions/http-client-csharp.instructions.md +++ b/.github/instructions/http-client-csharp.instructions.md @@ -26,3 +26,4 @@ applyTo: "packages/http-client-csharp/**/*" - Regenerate all generated libraries by running `eng/scripts/Generate.ps1`. - Ensure all unit tests are passing. - Do not comment out or delete any existing tests. +- Run the Cop static-analysis checks locally with `npm run cop` (which invokes `eng/scripts/Invoke-Cop.ps1`). This downloads the pinned Agent Cop release and runs the rules under `cop-checks/` against the generator, failing on any violation. Ensure it reports `cop checks passed.` before committing C# changes. diff --git a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 index d9b7bb768d9..f8f8f880acb 100644 --- a/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 +++ b/packages/http-client-csharp/eng/scripts/Invoke-Cop.ps1 @@ -38,7 +38,7 @@ param( # Pinned cop release. Bump deliberately after verifying the cop-checks/ rules # still run against the new release (cop can make breaking API changes # between releases). Pass "latest" to test against the newest release. - [string] $Version = "v2026.6.9.1" + [string] $Version = "v2026.6.10.1" ) $ErrorActionPreference = 'Stop' From 9e923c0db53240a601f18b1dce72e6188ae51e65 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:23:17 -0700 Subject: [PATCH 13/29] Skip generating convenience methods when the protocol method is suppressed without a replacement (#10950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convenience methods call into their protocol method, so when a client author suppresses the protocol methods via `[CodeGenSuppress]`, the generated convenience methods no longer compile. They should be skipped — unless the protocol method is replaced by custom code with the same signature, in which case the convenience method still compiles and should be kept. Paging convenience methods are an exception: they instantiate the collection result directly instead of calling the protocol method, so they are always generated (along with their paging helpers) regardless of protocol-method suppression. ### Changes (`http-client-csharp`) - **`MethodProvider.IsMethodSuppressed()`** — a focused instance predicate that returns `true` only when the method's signature is suppressed by a `[CodeGenSuppress]` attribute on its enclosing type. It no longer makes the full keep/skip decision by itself (the custom-replacement check lives in the caller). The predicate lives in the Generator assembly so the `[CodeGenSuppress]` matching helpers can stay non-public: `TypeProvider.GetMemberSuppressionAttributes` and the method `IsMatch` overload are now `internal` (previously the matching had to be reached through a public `TypeProvider.IsMethodSuppressed`). The predicate itself is `public` because `ScmMethodProviderCollection` (its caller) is not a `MethodProvider` subclass and there is no `InternalsVisibleTo` from the Generator assembly to the production `Microsoft.TypeSpec.Generator.ClientModel` assembly, so `protected internal` is not reachable from the call site. - **`ScmMethodProviderCollection.ProtocolMethodExists(MethodProvider generatedProtocolMethod)`** — decides whether each convenience method (sync/async) is generated. The protocol method is considered to exist (so the convenience method is kept) unless it was suppressed **and** the client's custom code provides no non-partial replacement with the same signature. The check reads `EnclosingType.CustomCodeView?.Methods` directly rather than enumerating `CanonicalView.Methods`, because the latter rebuilds the client's methods while they are being built, causing infinite recursion. - **`ScmMethodProviderCollection.BuildMethods`** — gates each convenience method on `_pagingServiceMethod != null || ProtocolMethodExists(protocolMethod)`. Paging convenience methods don't call the protocol method (they instantiate the `CollectionResultDefinition` directly via `new {collection}(this, ...)`), so suppressing the protocol method does not break them and they are always generated. This also ensures the paging helpers — including the typed `...CollectionResultOfT` collection-result definition, which is only created during convenience-method building — continue to be emitted so that custom code referencing them keeps compiling. ### Behavior ```csharp // Protocol suppressed, no replacement -> convenience method skipped (would not compile) [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] public partial class TestClient { } // Protocol suppressed but replaced in custom code -> convenience method still generated [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] public partial class TestClient { public virtual ClientResult HelloAgain(RequestOptions options) { ... } } // Protocol suppressed but only customized with an overload that has an extra parameter // (different signature) -> convenience method still skipped (no matching replacement) [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] public partial class TestClient { public virtual ClientResult HelloAgain(string extra, RequestOptions options) { ... } } // Paging protocol suppressed -> paging convenience methods AND collection-result helpers // are still generated (the convenience method instantiates the collection directly) [CodeGenSuppress("GetItems", typeof(RequestOptions))] public partial class TestClient { } ``` ### Tests Added to `ClientProviderCustomizationTests`: - `SuppressedProtocolMethodSkipsConvenienceMethod` — suppressed, no replacement → no convenience methods. - `SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod` — suppressed + custom replacement → convenience methods retained, generated protocol overloads dropped. Each generated convenience method is written with `CodeWriter.WriteMethod` and the entire method (signature + body) is validated against TestData golden files. - `SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod` — suppressed + custom overload with an additional parameter (different signature) → not treated as a replacement, so the convenience method is still skipped. - `SuppressedPagingProtocolMethodKeepsPagingHelpers` — paging protocol methods suppressed via custom code that references the paging helper → both the paging convenience methods and all collection-result helpers (`...CollectionResult`, `...AsyncCollectionResult`, `...CollectionResultOfT`, `...AsyncCollectionResultOfT`) are still generated. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../Providers/ScmMethodProviderCollection.cs | 47 ++++- .../ClientProviderCustomizationTests.cs | 167 ++++++++++++++++++ .../TestClient.cs | 18 ++ .../TestClient.cs | 14 ++ ...CustomCodeKeepsConvenienceMethod(Async).cs | 4 + ...hCustomCodeKeepsConvenienceMethod(Sync).cs | 4 + .../TestClient.cs | 25 +++ .../TestClient.cs | 25 +++ .../src/Providers/MethodProvider.cs | 18 ++ .../src/Providers/TypeProvider.cs | 8 +- 10 files changed, 323 insertions(+), 7 deletions(-) create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs index 1cced6bbb5d..a883d0321e0 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -91,13 +91,31 @@ protected virtual IReadOnlyList BuildMethods() if (_generateConvenienceMethod) { - return - [ + var methods = new List + { syncProtocol, asyncProtocol, - BuildConvenienceMethod(syncProtocol, false), - BuildConvenienceMethod(asyncProtocol, true), - ]; + }; + + if (_pagingServiceMethod != null) + { + methods.Add(BuildConvenienceMethod(syncProtocol, false)); + methods.Add(BuildConvenienceMethod(asyncProtocol, true)); + } + else + { + if (ProtocolMethodExists(syncProtocol)) + { + methods.Add(BuildConvenienceMethod(syncProtocol, false)); + } + + if (ProtocolMethodExists(asyncProtocol)) + { + methods.Add(BuildConvenienceMethod(asyncProtocol, true)); + } + } + + return methods; } return @@ -107,6 +125,25 @@ protected virtual IReadOnlyList BuildMethods() ]; } + private bool ProtocolMethodExists(MethodProvider generatedProtocolMethod) + { + if (!generatedProtocolMethod.IsMethodSuppressed()) + { + return true; + } + + foreach (var method in EnclosingType.CustomCodeView?.Methods ?? []) + { + if (!method.IsPartialMethod && + MethodSignatureBase.SignatureComparer.Equals(method.Signature, generatedProtocolMethod.Signature)) + { + return true; + } + } + + return false; + } + private ScmMethodProvider BuildConvenienceMethod(MethodProvider protocolMethod, bool isAsync) { if (EnclosingType is not ClientProvider client) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs index b7c64f4be5e..72ee46c9658 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderCustomizationTests.cs @@ -2,9 +2,11 @@ // Licensed under the MIT License. using System.ClientModel; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator; using Microsoft.TypeSpec.Generator.ClientModel.Providers; using Microsoft.TypeSpec.Generator.Input; using Microsoft.TypeSpec.Generator.Primitives; @@ -154,6 +156,171 @@ public async Task CanReplaceOpMethod() } + // Validates that when the protocol method is suppressed via [CodeGenSuppress] without a custom + // replacement, the convenience method (which calls the protocol method) is not generated either, + // since it would not compile. + [Test] + public async Task SuppressedProtocolMethodSkipsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // Both the suppressed protocol methods and the dependent convenience methods should be gone. + var helloAgainMethods = clientProvider!.Methods + .Where(m => m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") + .ToList(); + Assert.AreEqual(0, helloAgainMethods.Count); + } + + // Validates that when the protocol method is suppressed via [CodeGenSuppress] but replaced by a + // custom (non-partial) method implementation, the convenience method is still generated because + // it will compile against the custom protocol method. + [Test] + public async Task SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // The generated protocol methods are suppressed (provided by custom code), but the convenience + // methods (taking a CancellationToken) should still be generated. + var syncConvenience = clientProvider!.Methods.SingleOrDefault(m => + m.Signature.Name == "HelloAgain" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))); + var asyncConvenience = clientProvider.Methods.SingleOrDefault(m => + m.Signature.Name == "HelloAgainAsync" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))); + + Assert.IsNotNull(syncConvenience); + Assert.IsNotNull(asyncConvenience); + + // Validate the generated convenience methods (signature and body) still call into the + // (custom) protocol methods. + string syncActual; + using (var syncWriter = new CodeWriter()) + { + syncWriter.WriteMethod(syncConvenience!); + syncActual = syncWriter.ToString(false); + } + + string asyncActual; + using (var asyncWriter = new CodeWriter()) + { + asyncWriter.WriteMethod(asyncConvenience!); + asyncActual = asyncWriter.ToString(false); + } + + Assert.AreEqual(Helpers.GetExpectedFromFile("Sync"), syncActual); + Assert.AreEqual(Helpers.GetExpectedFromFile("Async"), asyncActual); + + // The generated protocol methods (taking RequestOptions) should be suppressed in favor of the custom ones. + var generatedProtocolMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(RequestOptions)))) + .ToList(); + Assert.AreEqual(0, generatedProtocolMethods.Count); + } + + // Validates that when the protocol method is suppressed via [CodeGenSuppress] and the customization + // only provides an overload with an additional parameter (a different signature), the convenience + // method is still skipped because no replacement with the matching protocol signature exists. + [Test] + public async Task SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod() + { + var inputOperation = InputFactory.Operation("HelloAgain"); + var inputServiceMethod = InputFactory.BasicServiceMethod("test", inputOperation); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = mockGenerator.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ClientProvider); + Assert.IsNotNull(clientProvider); + + // The custom overloads (with an additional parameter) do not match the suppressed protocol + // signature, so both the protocol and the dependent convenience methods should be gone. + var generatedHelloAgainMethods = clientProvider!.Methods + .Where(m => m.Signature.Name == "HelloAgain" || m.Signature.Name == "HelloAgainAsync") + .ToList(); + Assert.AreEqual(0, generatedHelloAgainMethods.Count); + + // The additional custom overload is still present in the custom code view. + var customMethods = clientProvider.CustomCodeView?.Methods ?? []; + Assert.AreEqual(2, customMethods.Count); + Assert.IsTrue(customMethods.All(m => m.Signature.Parameters.Count == 2)); + } + + // Validates that when a paging protocol method is suppressed via [CodeGenSuppress], the paging + // helpers (collection result definitions) are still generated so that custom code can reference + // them. Unlike non-paging convenience methods, paging convenience methods instantiate the + // collection result directly instead of calling the protocol method, so they are always generated. + [Test] + public async Task SuppressedPagingProtocolMethodKeepsPagingHelpers() + { + var inputModel = InputFactory.Model("item", properties: + [ + InputFactory.Property("color", InputPrimitiveType.String, isRequired: true), + ]); + var pagingMetadata = InputFactory.NextLinkPagingMetadata(["items"], ["nextLink"], InputResponseLocation.Body); + var response = InputFactory.OperationResponse( + [200], + InputFactory.Model( + "page", + properties: + [ + InputFactory.Property("items", InputFactory.Array(inputModel)), + InputFactory.Property("nextLink", InputPrimitiveType.Url), + ])); + var inputOperation = InputFactory.Operation("GetItems", responses: [response]); + var inputServiceMethod = InputFactory.PagingServiceMethod("GetItems", inputOperation, pagingMetadata: pagingMetadata); + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var mockGenerator = await MockHelpers.LoadMockGeneratorAsync( + inputModels: () => [inputModel], + clients: () => [inputClient], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + + var clientProvider = (ClientProvider)mockGenerator.Object.OutputLibrary.TypeProviders.Single(t => t is ClientProvider); + + // The generated protocol methods (taking RequestOptions) are suppressed. + var generatedProtocolMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "GetItems" || m.Signature.Name == "GetItemsAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(RequestOptions)))) + .ToList(); + Assert.AreEqual(0, generatedProtocolMethods.Count); + + // The paging convenience methods (taking a CancellationToken) are still generated because they + // instantiate the collection result directly rather than calling the suppressed protocol method. + var convenienceMethods = clientProvider.Methods + .Where(m => (m.Signature.Name == "GetItems" || m.Signature.Name == "GetItemsAsync") && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(System.Threading.CancellationToken)))) + .ToList(); + Assert.AreEqual(2, convenienceMethods.Count); + + // The paging helpers (collection result definitions) are still emitted so that the custom code + // referencing them continues to compile. + var collectionResultDefinitions = mockGenerator.Object.OutputLibrary.TypeProviders + .OfType() + .Select(t => t.Name) + .ToList(); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsCollectionResult"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsAsyncCollectionResult"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsCollectionResultOfT"); + CollectionAssert.Contains(collectionResultDefinitions, "TestClientGetItemsAsyncCollectionResultOfT"); + } + // Validates that a method with a struct parameter can be replaced [TestCase(true)] [TestCase(false)] diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs new file mode 100644 index 00000000000..34e4c7b1786 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedPagingProtocolMethodKeepsPagingHelpers/TestClient.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("GetItems", typeof(RequestOptions))] + [CodeGenSuppress("GetItemsAsync", typeof(RequestOptions))] + public partial class TestClient + { + // Custom code that references the generated paging helper to ensure it continues to be generated. + public virtual CollectionResult GetItemsCustom(RequestOptions options) + => new TestClientGetItemsCollectionResult(this, options); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..af279a5311c --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodSkipsConvenienceMethod/TestClient.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs new file mode 100644 index 00000000000..a43dc00338d --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Async).cs @@ -0,0 +1,4 @@ +public virtual async global::System.Threading.Tasks.Task HelloAgainAsync(global::System.Threading.CancellationToken cancellationToken = default) +{ + return await this.HelloAgainAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs new file mode 100644 index 00000000000..cbe70d92877 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod(Sync).cs @@ -0,0 +1,4 @@ +public virtual global::System.ClientModel.ClientResult HelloAgain(global::System.Threading.CancellationToken cancellationToken = default) +{ + return this.HelloAgain(cancellationToken.ToRequestOptions()); +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..80cd99288a5 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomCodeKeepsConvenienceMethod/TestClient.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + public virtual ClientResult HelloAgain(RequestOptions options) + { + + } + + public virtual Task HelloAgainAsync(RequestOptions options) + { + + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs new file mode 100644 index 00000000000..e7720439d07 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/SuppressedProtocolMethodWithCustomOverloadSkipsConvenienceMethod/TestClient.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Sample +{ + [CodeGenSuppress("HelloAgain", typeof(RequestOptions))] + [CodeGenSuppress("HelloAgainAsync", typeof(RequestOptions))] + public partial class TestClient + { + public virtual ClientResult HelloAgain(string extra, RequestOptions options) + { + + } + + public virtual Task HelloAgainAsync(string extra, RequestOptions options) + { + + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs index 207354db638..1ba1bb6ec7a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/MethodProvider.cs @@ -29,6 +29,24 @@ public class MethodProvider /// public bool IsPartialMethod => Signature?.Modifiers.HasFlag(MethodSignatureModifiers.Partial) ?? false; + /// + /// Determines whether this method is suppressed via a CodeGenSuppress attribute on its + /// enclosing type. A suppressed method may still be provided by custom code, so callers that need to + /// know whether the method exists in the final output must additionally check for a custom replacement. + /// + public bool IsMethodSuppressed() + { + foreach (var attribute in EnclosingType.GetMemberSuppressionAttributes()) + { + if (TypeProvider.IsMatch(EnclosingType, Signature, attribute)) + { + return true; + } + } + + return false; + } + // for mocking #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. protected MethodProvider() diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs index fb6e6e72f25..7a3047886b6 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs @@ -832,7 +832,11 @@ private static bool IsMatch(FieldProvider fieldProvider, AttributeData attribute return name == fieldProvider.Name; } - private static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase signature, AttributeData attribute) + /// + /// Determines whether the method with the given on + /// matches the given CodeGenSuppress . + /// + internal static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase signature, AttributeData attribute) { ValidateArguments(enclosingType, attribute); var name = attribute.ConstructorArguments[0].Value as string; @@ -992,7 +996,7 @@ private static string GetText(SyntaxReference? syntaxReference) private static FileLinePositionSpan GetFileLinePosition(SyntaxReference? syntaxReference) => syntaxReference?.SyntaxTree.GetLocation(syntaxReference.Span).GetLineSpan() ?? default; - private IEnumerable GetMemberSuppressionAttributes() + internal IEnumerable GetMemberSuppressionAttributes() => CustomCodeView?.Attributes.Where(a => a.Data?.AttributeClass?.Name == CodeGenAttributes.CodeGenSuppressAttributeName). Select(a => a.Data!).ToList() ?? []; } From 3c918ef231f2657a9557c3ffa57e9638d2e30963 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 11 Jun 2026 15:08:04 -0700 Subject: [PATCH 14/29] Revert "fix(http-client-csharp): strip [Experimental] attribute when internalizing types" (#10972) Reverts microsoft/typespec#10958 --- .../src/PostProcessing/PostProcessor.cs | 86 ----------------- .../test/PostProcessing/PostProcessorTests.cs | 96 ------------------- .../ExperimentalInternalizeRoot.cs | 7 -- .../ReferencedModel.cs | 12 --- .../UnreferencedModel.cs | 12 --- .../UnreferencedWithCombinedAttributes.cs | 13 --- .../UnreferencedWithOtherAttribute.cs | 14 --- 7 files changed, 240 deletions(-) delete mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs delete mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs delete mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs delete mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs delete mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs index 738174e7628..be96e11df59 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/PostProcessor.cs @@ -20,8 +20,6 @@ internal class PostProcessor private readonly HashSet _typesToKeep; private INamedTypeSymbol? _modelFactorySymbol; - private static readonly string[] _experimentalAttributeNames = ["Experimental", "ExperimentalAttribute"]; - public PostProcessor( HashSet typesToKeep, string? modelFactoryFullName = null, @@ -158,12 +156,6 @@ public async Task InternalizeAsync(Project project) project = MarkInternal(project, model, documentId); } - if (nodesToInternalize.Count > 0) - { - CodeModelGenerator.Instance.Emitter.Info( - $"Internalized {nodesToInternalize.Count} unreferenced public type(s)."); - } - var modelNamesToRemove = nodesToInternalize.Keys.Select(item => item.Identifier.Text); project = await RemoveMethodsFromModelFactoryAsync(project, definitions, modelNamesToRemove.ToHashSet()); @@ -344,13 +336,7 @@ private static IEnumerable GetReferencedTypes(T definition, private Project MarkInternal(Project project, BaseTypeDeclarationSyntax declarationNode, DocumentId documentId) { - CodeModelGenerator.Instance.Emitter.Debug( - $"Internalizing unreferenced public type '{declarationNode.Identifier.Text}'."); - var newNode = ChangeModifier(declarationNode, SyntaxKind.PublicKeyword, SyntaxKind.InternalKeyword); - // The [Experimental] attribute is a public-API stability signal that is meaningless on a type that is - // being internalized, so strip it to avoid emitting it (and its use-site diagnostics) on internal types. - newNode = RemoveExperimentalAttribute(newNode, declarationNode.Identifier.Text); var tree = declarationNode.SyntaxTree; var document = project.GetDocument(documentId)!; var newRoot = tree.GetRoot().ReplaceNode(declarationNode, newNode) @@ -359,78 +345,6 @@ private Project MarkInternal(Project project, BaseTypeDeclarationSyntax declarat return document.Project; } - /// - /// Removes any [Experimental] () - /// attribute from . The declaration's leading trivia (such as documentation - /// comments and indentation) is re-attached to the resulting first token so that the surrounding formatting and - /// any documentation comment are preserved even when the attribute that carried them is removed. - /// - private static BaseTypeDeclarationSyntax RemoveExperimentalAttribute( - BaseTypeDeclarationSyntax declarationNode, - string typeName) - { - if (declarationNode.AttributeLists.Count == 0) - { - return declarationNode; - } - - var newAttributeLists = new List(); - bool removed = false; - - foreach (var attributeList in declarationNode.AttributeLists) - { - var keptAttributes = attributeList.Attributes - .Where(attribute => !IsExperimentalAttribute(attribute)) - .ToList(); - - if (keptAttributes.Count == attributeList.Attributes.Count) - { - // Nothing removed from this list. - newAttributeLists.Add(attributeList); - } - else if (keptAttributes.Count > 0) - { - // Keep the remaining (non-experimental) attributes in this list. - removed = true; - newAttributeLists.Add(attributeList.WithAttributes(SyntaxFactory.SeparatedList(keptAttributes))); - } - else - { - // The entire list only contained experimental attributes and is dropped. - removed = true; - } - } - - if (!removed) - { - return declarationNode; - } - - CodeModelGenerator.Instance.Emitter.Debug( - $"Removed [Experimental] attribute from '{typeName}' while internalizing it."); - - // Preserve the original leading trivia (e.g. documentation comments and indentation) by re-attaching it to - // whatever token now leads the declaration. This keeps the doc comment even when it was attached to the - // attribute list that was removed. - var originalLeadingTrivia = declarationNode.GetLeadingTrivia(); - var newNode = declarationNode.WithAttributeLists(SyntaxFactory.List(newAttributeLists)); - var firstToken = newNode.GetFirstToken(); - - return newNode.ReplaceToken(firstToken, firstToken.WithLeadingTrivia(originalLeadingTrivia)); - } - - private static bool IsExperimentalAttribute(AttributeSyntax attribute) - { - var name = attribute.Name switch - { - QualifiedNameSyntax qualified => qualified.Right.Identifier.Text, - IdentifierNameSyntax identifier => identifier.Identifier.Text, - _ => attribute.Name.ToString() - }; - - return Array.IndexOf(_experimentalAttributeNames, name) >= 0; - } - private async Task RemoveModelsAsync(Project project, IEnumerable unusedModels) { diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs index ebd37a0c146..28981148a4d 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/PostProcessorTests.cs @@ -3,12 +3,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.TypeSpec.Generator.Tests.Common; using NUnit.Framework; @@ -291,100 +289,6 @@ public async Task DoesNotRemoveValidAttributes() Assert.AreEqual(Helpers.GetExpectedFromFile().TrimEnd(), output, "The output should match the expected content."); } - [Test] - public async Task RemovesExperimentalAttributeWhenInternalizing() - { - MockHelpers.LoadMockGenerator(); - var workspace = new AdhocWorkspace(); - var projectInfo = ProjectInfo.Create( - ProjectId.CreateNewId(), - VersionStamp.Create(), - name: "TestProj", - assemblyName: "TestProj", - language: LanguageNames.CSharp) - .WithMetadataReferences(new[] - { - MetadataReference.CreateFromFile(typeof(object).Assembly.Location), - MetadataReference.CreateFromFile(typeof(ExperimentalAttribute).Assembly.Location) - }); - - var project = workspace.AddProject(projectInfo); - var folder = Helpers.GetAssetFileOrDirectoryPath(false); - const string rootFileName = "ExperimentalInternalizeRoot.cs"; - string[] modelFileNames = - [ - "ReferencedModel.cs", - "UnreferencedModel.cs", - "UnreferencedWithOtherAttribute.cs", - "UnreferencedWithCombinedAttributes.cs" - ]; - foreach (var fileName in modelFileNames) - { - project = project.AddDocument( - fileName, - File.ReadAllText(Path.Join(folder, fileName))).Project; - } - project = project.AddDocument( - rootFileName, - File.ReadAllText(Path.Join(folder, rootFileName))).Project; - var postProcessor = new TestPostProcessor(rootFileName); - - var resultProject = await postProcessor.InternalizeAsync(project); - - var referencedModel = await GetSingleClassAsync(resultProject, "ReferencedModel.cs", "ReferencedModel"); - var unreferencedModel = await GetSingleClassAsync(resultProject, "UnreferencedModel.cs", "UnreferencedModel"); - var unreferencedWithOther = await GetSingleClassAsync(resultProject, "UnreferencedWithOtherAttribute.cs", "UnreferencedWithOtherAttribute"); - var unreferencedWithCombined = await GetSingleClassAsync(resultProject, "UnreferencedWithCombinedAttributes.cs", "UnreferencedWithCombinedAttributes"); - - // The referenced model stays public and keeps its [Experimental] attribute. - Assert.IsTrue(referencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword))); - Assert.IsTrue(HasExperimentalAttribute(referencedModel), "Referenced (public) model should keep [Experimental]."); - - // The unreferenced model is internalized and loses its [Experimental] attribute. - Assert.IsTrue(unreferencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); - Assert.IsFalse(unreferencedModel.Modifiers.Any(m => m.IsKind(SyntaxKind.PublicKeyword))); - Assert.IsFalse(HasExperimentalAttribute(unreferencedModel), "Internalized model should not keep [Experimental]."); - - // The documentation comment on the internalized type is preserved. - Assert.IsTrue( - unreferencedModel.GetLeadingTrivia().ToFullString().Contains("not referenced"), - "Doc comment of the internalized type should be preserved."); - - // An internalized type with another attribute in a separate list keeps the other attribute. - Assert.IsTrue(unreferencedWithOther.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); - Assert.IsFalse(HasExperimentalAttribute(unreferencedWithOther), "Internalized model should not keep [Experimental]."); - Assert.IsTrue(HasAttribute(unreferencedWithOther, "Serializable"), "Other attributes should be preserved."); - Assert.IsTrue( - unreferencedWithOther.GetLeadingTrivia().ToFullString().Contains("must be preserved"), - "Doc comment should be preserved when only one of several attribute lists is removed."); - - // An internalized type with the experimental attribute combined in a single list keeps the others. - Assert.IsTrue(unreferencedWithCombined.Modifiers.Any(m => m.IsKind(SyntaxKind.InternalKeyword))); - Assert.IsFalse(HasExperimentalAttribute(unreferencedWithCombined), "Internalized model should not keep [Experimental]."); - Assert.IsTrue(HasAttribute(unreferencedWithCombined, "Serializable"), "Other attributes in the same list should be preserved."); - } - - private static async Task GetSingleClassAsync(Project project, string fileName, string className) - { - var doc = project.Documents.Single(d => d.Name == fileName); - var root = await doc.GetSyntaxRootAsync(); - return ((CompilationUnitSyntax)root!) - .DescendantNodes() - .OfType() - .Single(t => t.Identifier.Text == className); - } - - private static bool HasAttribute(BaseTypeDeclarationSyntax type, string attributeName) - => type.AttributeLists - .SelectMany(list => list.Attributes) - .Any(attr => attr.Name.ToString() == attributeName); - - - private static bool HasExperimentalAttribute(BaseTypeDeclarationSyntax type) - => type.AttributeLists - .SelectMany(list => list.Attributes) - .Any(attr => attr.Name.ToString() is "Experimental" or "ExperimentalAttribute"); - private class TestPostProcessor : PostProcessor { private readonly string _rootFile; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs deleted file mode 100644 index 350fb5fdbba..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ExperimentalInternalizeRoot.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Sample -{ - public class ExperimentalInternalizeRoot - { - public ReferencedModel Model { get; set; } - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs deleted file mode 100644 index 877443f345a..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/ReferencedModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Sample -{ - /// - /// A model that is referenced from a root type and therefore stays public. - /// - [Experimental("EXP001")] - public class ReferencedModel - { - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs deleted file mode 100644 index 727b2c097d4..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Sample -{ - /// - /// A model that is not referenced from any root type and is internalized. - /// - [Experimental("EXP001")] - public class UnreferencedModel - { - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs deleted file mode 100644 index 5a2afab2013..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithCombinedAttributes.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Sample -{ - /// - /// An unreferenced model with the experimental attribute combined in a single list. - /// - [Serializable, Experimental("EXP001")] - public class UnreferencedWithCombinedAttributes - { - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs deleted file mode 100644 index 5d970ad6d99..00000000000 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/PostProcessing/TestData/PostProcessorTests/RemovesExperimentalAttributeWhenInternalizing/UnreferencedWithOtherAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Sample -{ - /// - /// An unreferenced model that carries another attribute which must be preserved. - /// - [Serializable] - [Experimental("EXP001")] - public class UnreferencedWithOtherAttribute - { - } -} From 7d060ec4a52fa41a9dbc685691b51d0d1b52f87e Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Jun 2026 22:24:54 +0000 Subject: [PATCH 15/29] Skip convenience method generation for multipart/mixed requests (#10967) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C# emitter does not support `multipart/mixed` requests, yet since the addition of `multipart/form-data` support it would emit an incorrect convenience method for them. This disables convenience method generation for multipart content types other than `multipart/form-data` and surfaces a diagnostic instead. The detection lives in the emitter so the generator simply honors the resulting `generateConvenienceMethod` flag. ### Changes - **`operation-converter.ts`**: In `fromSdkServiceMethodOperation`, when an operation uses a `multipart/*` content type other than `multipart/form-data`, `generateConvenienceMethod` is set to `false` (protocol methods still emitted) and a warning diagnostic is reported. A small `isUnsupportedMultipart` helper inspects the request media types. - **`lib.ts`**: Added the `unsupported-multipart-convenience-method` warning diagnostic. - **Tests**: Added emitter unit tests in `operation-converter.test.ts` — `multipart/mixed` turns off convenience method generation and emits the warning, while `multipart/form-data` keeps convenience methods with no diagnostic. ```ts const requestMediaTypes = getRequestMediaTypes(method.operation); if (generateConvenience && isUnsupportedMultipart(requestMediaTypes)) { diagnostics.add( createDiagnostic({ code: "unsupported-multipart-convenience-method", format: { methodCrossLanguageDefinitionId: method.crossLanguageDefinitionId }, target: method.__raw ?? NoTarget, }), ); generateConvenience = false; } ``` No existing test specs use `multipart/mixed`, so generated library output is unchanged. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../http-client-csharp/emitter/src/lib/lib.ts | 6 ++ .../emitter/src/lib/operation-converter.ts | 25 +++++- .../test/Unit/operation-converter.test.ts | 76 +++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/packages/http-client-csharp/emitter/src/lib/lib.ts b/packages/http-client-csharp/emitter/src/lib/lib.ts index c93ac07963d..a3c5c96a649 100644 --- a/packages/http-client-csharp/emitter/src/lib/lib.ts +++ b/packages/http-client-csharp/emitter/src/lib/lib.ts @@ -95,6 +95,12 @@ const diags: { [code: string]: DiagnosticDefinition } = { default: paramMessage`Convenience method is not supported for PATCH method, it will be turned off. Please set the '@convenientAPI' to false for operation ${"methodCrossLanguageDefinitionId"}.`, }, }, + "unsupported-multipart-convenience-method": { + severity: "warning", + messages: { + default: paramMessage`Convenience method is not supported for multipart content types other than 'multipart/form-data', it will be turned off. Please set the '@convenientAPI' to false for operation ${"methodCrossLanguageDefinitionId"}.`, + }, + }, "unsupported-service-method": { severity: "warning", messages: { diff --git a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts index 72ef7d9f109..59f35f75e03 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts @@ -196,6 +196,20 @@ export function fromSdkServiceMethodOperation( generateConvenience = false; } + const requestMediaTypes = getRequestMediaTypes(method.operation); + if (generateConvenience && isUnsupportedMultipart(requestMediaTypes)) { + diagnostics.add( + createDiagnostic({ + code: "unsupported-multipart-convenience-method", + format: { + methodCrossLanguageDefinitionId: method.crossLanguageDefinitionId, + }, + target: method.__raw ?? NoTarget, + }), + ); + generateConvenience = false; + } + operation = { name: method.name, isExactName: method.isExactName, @@ -217,7 +231,7 @@ export function fromSdkServiceMethodOperation( uri: uri, path: method.operation.path, externalDocsUrl: getExternalDocs(sdkContext, method.operation.__raw.operation)?.url, - requestMediaTypes: getRequestMediaTypes(method.operation), + requestMediaTypes: requestMediaTypes, bufferResponse: true, generateProtocolMethod: shouldGenerateProtocol(sdkContext, method.operation.__raw.operation), generateConvenienceMethod: generateConvenience, @@ -751,6 +765,15 @@ function toStatusCodesArray(range: number | HttpStatusCodeRange): number[] { return statusCodes; } +function isUnsupportedMultipart(requestMediaTypes: string[] | undefined): boolean { + return ( + requestMediaTypes?.some((mediaType) => { + const normalized = mediaType.toLowerCase(); + return normalized.startsWith("multipart/") && normalized !== "multipart/form-data"; + }) ?? false + ); +} + function getRequestMediaTypes(op: SdkHttpOperation): string[] | undefined { const contentTypes = op.parameters.filter( (p) => p.kind === "header" && p.serializedName.toLocaleLowerCase() === "content-type", diff --git a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts index 7671caabb97..3863f242393 100644 --- a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts @@ -622,3 +622,79 @@ describe("Test isExactName propagation on operations and parameters", () => { strictEqual(method.operation.isExactName, true); }); }); + +describe("Multipart convenience method generation", () => { + let runner: TestHost; + + beforeEach(async () => { + runner = await createEmitterTestHost(); + }); + + it("disables convenience method for multipart/mixed and reports a diagnostic", async () => { + const program = await typeSpecCompile( + ` + model MultipartRequest { + id: HttpPart; + profileImage: HttpPart; + } + + @post + @route("/upload") + op upload( + @header contentType: "multipart/mixed", + @multipartBody body: MultipartRequest, + ): NoContentResponse; + `, + runner, + { IsTCGCNeeded: true }, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const [root, diagnostics] = createModel(sdkContext); + + const operation = root.clients[0].methods[0].operation; + ok(operation); + ok(operation.requestMediaTypes?.includes("multipart/mixed")); + // Protocol methods are still generated, but convenience methods are turned off. + strictEqual(operation.generateProtocolMethod, true); + strictEqual(operation.generateConvenienceMethod, false); + + const diagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-multipart-convenience-method", + ); + ok(diagnostic); + strictEqual(diagnostic.severity, "warning"); + }); + + it("keeps convenience method for multipart/form-data without a diagnostic", async () => { + const program = await typeSpecCompile( + ` + model MultipartRequest { + profileImage: HttpPart; + } + + @post + @route("/upload") + op upload( + @header contentType: "multipart/form-data", + @multipartBody body: MultipartRequest, + ): NoContentResponse; + `, + runner, + { IsTCGCNeeded: true }, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const [root, diagnostics] = createModel(sdkContext); + + const operation = root.clients[0].methods[0].operation; + ok(operation); + ok(operation.requestMediaTypes?.includes("multipart/form-data")); + strictEqual(operation.generateConvenienceMethod, true); + + const diagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-multipart-convenience-method", + ); + strictEqual(diagnostic, undefined); + }); +}); From df0536505b3153585d2f71fe6ed94362f6116a90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:39:22 -0400 Subject: [PATCH 16/29] Bump MessagePack from 2.5.192 to 2.5.301 (#10975) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated [MessagePack](https://github.com/MessagePack-CSharp/MessagePack-CSharp) from 2.5.192 to 2.5.301.
Release notes _Sourced from [MessagePack's releases](https://github.com/MessagePack-CSharp/MessagePack-CSharp/releases)._ ## 2.5.301 ## Security release This release fixes 2 high severity and 9 moderate severity security vulnerabilities as listed below. This release is missing #​2269 from the v2.5.205 release. We recommend folks adopt the v2.5.302 release which has all the security fixes combined. ### High severity advisory fixes - 696b4a76 GHSA-vh6j-jc39-fggf Use iteration for skipping msgpack structures for CWE-674 - 3538bc11 GHSA-hv8m-jj95-wg3x Bound LZ4 input reads for CWE-125 ### Moderage severity advisory fixes - 853429a0 GHSA-v72x-2h86-7f8m Guard LZ4 decompression length for CWE-409 - 826f17c7 GHSA-qhmf-xw27-6rqr Reject nested typeless blocklist bypass for CWE-502 - c98d31f2 GHSA-2f33-pr97-265q Default MVC input formatter to UntrustedData for CWE-1188 - ae90f2b1 GHSA-2x83-8g95-xh59 Limit untrusted ExpandoObject maps for CWE-407 - 940b8508 GHSA-wfr3-xj75-pfwh Guard dynamic union depth for CWE-674 - e01f07cf GHSA-w567-gjr2-hm5j Validate Unity blit lengths for CWE-789 - dc6f6324 GHSA-cxmj-83gh-fp49 Fix CWE-789 multidimensional array allocation validation - e97f71e7 GHSA-q2h6-ghwm-5qm8 Use secure lookup comparer for CWE-407 - 7b12e5b5 GHSA-cj9g-3mj2-g8vv Guard JSON conversion depth for CWE-674 - a3c8a183 GHSA-cj9g-3mj2-g8vv Avoid JSON separator recursion for CWE-674 - 96743523 GHSA-cj9g-3mj2-g8vv Guard typeless JSON depth for CWE-674 ### Fixes with no security advisory - 814bc4c1 Honor TypeFormatter options hooks for CWE-470 - b0f8c5e2 Fix WriteRawX methods to advance by written length - 0124048c Fix CWE-190 map header length overflow ## 2.5.205 ## What's Changed * Fix repo url by @​tomap in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2065 * Update DynamicAssembly usage to honor different AssemblyLoadContext's by @​BertanAygun in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2183 * Add more types to the default disallow list of named types to be deserialized by @​AArnott in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2263 * Add several known unsafe 'gadgets' to the disallow list by @​AArnott in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2269 ## New Contributors * @​tomap made their first contribution in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2065 **Full Changelog**: https://github.com/MessagePack-CSharp/MessagePack-CSharp/compare/v2.5.192...v2.5.205 ## 2.5.198 ## What's Changed * Fix repo url by @​tomap in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2065 * Update DynamicAssembly usage to honor different AssemblyLoadContext's by @​BertanAygun in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2183 ## New Contributors * @​tomap made their first contribution in https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/2065 **Full Changelog**: https://github.com/MessagePack-CSharp/MessagePack-CSharp/compare/v2.5.192...v2.5.198 Commits viewable in [compare view](https://github.com/MessagePack-CSharp/MessagePack-CSharp/compare/v2.5.192...v2.5.301).
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=MessagePack&package-manager=nuget&previous-version=2.5.192&new-version=2.5.301)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/microsoft/typespec/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj b/packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj index 804b1067d02..71611c8aa97 100644 --- a/packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj +++ b/packages/typespec-vs/src/Microsoft.TypeSpec.VS.csproj @@ -34,7 +34,7 @@ - + Always From c018877b1ce49f451edd293e6df96e660027ac88 Mon Sep 17 00:00:00 2001 From: Libba Lawrence Date: Thu, 11 Jun 2026 19:22:34 -0700 Subject: [PATCH 17/29] [python] Fix Sphinx docstring rendering of annotations after code blocks (#10955) ## Why Fixes #10314. When a property or parameter description ended with a code block, the emitter appended annotations like `Required.` to the very end of the string. With code blocks converted to RST `.. code-block::`, the annotation landed right after the closing `]` of a JSON block (`]. Required.`), which breaks Sphinx rendering. ## Approach Annotations are added centrally in `add_to_description` (in `pygen/codegen/models/utils.py`), used by both `property.py` and `parameter.py` and other callers. That helper is now code-block aware: when the description contains `.. code-block::`, the annotation is inserted into the prose **before** the code block instead of being appended after it. Behavior is unchanged when there is no code block. ## Tests Added `tests/unit/test_add_to_description.py` covering the empty, plain, single-code-block, and multiple-code-block cases. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Yuchao Yan --- ...uired-after-code-block-2026-6-9-15-20-0.md | 7 +++ .../generator/pygen/codegen/models/utils.py | 24 ++++++++-- .../tests/unit/test_add_to_description.py | 48 +++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 .chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md create mode 100644 packages/http-client-python/tests/unit/test_add_to_description.py diff --git a/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md b/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md new file mode 100644 index 00000000000..cf2ec9852d7 --- /dev/null +++ b/.chronus/changes/fix-sphinx-required-after-code-block-2026-6-9-15-20-0.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix Sphinx docstring rendering when a `Required.` (or other) annotation followed a code block. The annotation is now inserted into the prose before the code block instead of being appended after it. diff --git a/packages/http-client-python/generator/pygen/codegen/models/utils.py b/packages/http-client-python/generator/pygen/codegen/models/utils.py index 82e80b85577..46aa53f749c 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/utils.py +++ b/packages/http-client-python/generator/pygen/codegen/models/utils.py @@ -11,10 +11,20 @@ OrderedSet = dict[T, None] +CODE_BLOCK_MARKER = ".. code-block::" + + def add_to_description(description: str, entry: str) -> str: - if description: - return f"{description} {entry}" - return entry + if not description: + return entry + # When the description contains a code block, the entry (e.g. "Required.") must be + # inserted into the prose *before* the code block. Appending it after the code block + # (e.g. "]. Required.") leaves it dangling at the end of the rendered block and breaks + # Sphinx rendering. + if CODE_BLOCK_MARKER in description: + prose, _, code_block = description.partition(CODE_BLOCK_MARKER) + return f"{prose.rstrip()} {entry}\n\n{CODE_BLOCK_MARKER}{code_block}" + return f"{description} {entry}" def add_to_pylint_disable(curr_str: str, entry: str) -> str: @@ -34,6 +44,10 @@ class NamespaceType(str, Enum): LOCALS_LENGTH_LIMIT = 25 -REQUEST_BUILDER_BODY_VARIABLES_LENGTH = 6 # how many body variables are present in a request builder +REQUEST_BUILDER_BODY_VARIABLES_LENGTH = ( + 6 # how many body variables are present in a request builder +) -OPERATION_BODY_VARIABLES_LENGTH = 14 # how many body variables are present in an operation +OPERATION_BODY_VARIABLES_LENGTH = ( + 14 # how many body variables are present in an operation +) diff --git a/packages/http-client-python/tests/unit/test_add_to_description.py b/packages/http-client-python/tests/unit/test_add_to_description.py new file mode 100644 index 00000000000..7ba4e11acd7 --- /dev/null +++ b/packages/http-client-python/tests/unit/test_add_to_description.py @@ -0,0 +1,48 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +"""Tests for add_to_description code-block handling.""" +from pygen.codegen.models.utils import add_to_description + + +def test_add_to_description_empty() -> None: + assert add_to_description("", "Required.") == "Required." + + +def test_add_to_description_plain() -> None: + assert add_to_description("The tools.", "Required.") == "The tools. Required." + + +def test_add_to_description_inserts_before_code_block() -> None: + description = "The tools to use.\n\n.. code-block:: json\n\n [\n 1\n ]" + result = add_to_description(description, "Required.") + assert result == ( + "The tools to use. Required.\n\n.. code-block:: json\n\n [\n 1\n ]" + ) + # The annotation must not be appended after the closing of the code block. + assert not result.rstrip().endswith("Required.") + + +def test_add_to_description_chained_annotations_stay_before_code_block() -> None: + # Mirrors parameter.py, where add_to_description is called repeatedly on the + # same description (known values, Required., default value, ...). + description = "The tools to use.\n\n.. code-block:: json\n\n [1]" + description = add_to_description(description, "Known values are X and None.") + description = add_to_description(description, "Required.") + description = add_to_description(description, "Default value is None.") + assert description == ( + "The tools to use. Known values are X and None. Required. Default value is None." + "\n\n.. code-block:: json\n\n [1]" + ) + + +def test_add_to_description_multiple_code_blocks_inserts_before_first() -> None: + description = ( + "Prose.\n\n.. code-block:: json\n\n [1]\n\n.. code-block:: json\n\n [2]" + ) + result = add_to_description(description, "Required.") + assert result == ( + "Prose. Required.\n\n.. code-block:: json\n\n [1]\n\n.. code-block:: json\n\n [2]" + ) From 5b8f8dc428819ede539ea7b10e65be5ddc620aab Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 11 Jun 2026 19:42:30 -0700 Subject: [PATCH 18/29] feat(http-client-csharp): add disable-roslyn-reduce emitter option (#10971) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Adds a new `disable-roslyn-reduce` boolean emitter option to the C# emitter. When set to `true`, the generator skips the Roslyn `Simplifier.ReduceAsync` post-processing step. This is useful for iterating more quickly during development, and is something we may want to expose in the TypeSpec playground as well. The option defaults to `false`, so existing behavior is unchanged. ## Changes - `emitter/src/options.ts` — add `disable-roslyn-reduce` to `CSharpEmitterOptions` and its JSON schema. - `emitter/src/type/configuration.ts` — add the option to the `Configuration` type. - `emitter/src/emitter.ts` — thread the option into the generated `Configuration.json`. - `generator/Microsoft.TypeSpec.Generator/src/Configuration.cs` — parse the option (`DisableRoslynReduce`). - `generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs` — skip `Simplifier.ReduceAsync` when enabled. - Docs (`docs/emitter.md`, `readme.md`) and unit tests updated. ## Performance data Measured by running the generator (`Microsoft.TypeSpec.Generator.exe`) directly against saved code models, after a warmup, reduce step on (default) vs. off (`disable-roslyn-reduce: true`): | Spec | Reduce on (avg s) | Reduce off (avg s) | Improvement | | --- | --- | --- | --- | | `Sample-TypeSpec` (5 runs) | 21.79 | 11.99 | ~45% faster | | `type/property/additional-properties` (3 runs) | 5.58 | 3.61 | ~35% faster | | `type/property/value-types` (3 runs) | 4.50 | 3.17 | ~30% faster | | `special-words` (3 runs) | 4.53 | 3.37 | ~26% faster | | `type/file` (3 runs) | 0.96 | 1.04 | negligible* | \* `type/file` has a large code model but generates very little code, so the reduce step is not a meaningful portion of its runtime; the difference is within run-to-run noise. The more code a library generates, the larger the win — `Sample-TypeSpec` (a large, code-heavy project) sees roughly a 45% reduction in generation time. ## Testing - `ConfigurationTests` (added `DisableRoslynReduce_ParsedFromConfig` / `_DefaultsToFalse`) — 24 passed. - Emitter `options.test.ts` extended — 6 passed. - `npm run build` (emitter + generator + api-extractor) succeeds. --generated by Copilot --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/http-client-csharp/docs/emitter.md | 6 +++++ .../http-client-csharp/emitter/src/emitter.ts | 2 ++ .../http-client-csharp/emitter/src/options.ts | 8 ++++++ .../emitter/src/type/configuration.ts | 1 + .../emitter/test/Unit/options.test.ts | 2 ++ .../src/Configuration.cs | 17 ++++++++++-- .../PostProcessing/GeneratedCodeWorkspace.cs | 5 +++- .../test/ConfigurationTests.cs | 27 +++++++++++++++++++ packages/http-client-csharp/readme.md | 6 +++++ .../http-client-csharp/reference/emitter.md | 6 +++++ 10 files changed, 77 insertions(+), 3 deletions(-) diff --git a/packages/http-client-csharp/docs/emitter.md b/packages/http-client-csharp/docs/emitter.md index 1f968bcce9f..827da57427a 100644 --- a/packages/http-client-csharp/docs/emitter.md +++ b/packages/http-client-csharp/docs/emitter.md @@ -96,6 +96,12 @@ Set the log level for which to collect traces. The default value is `info`. Set to `true` to disable XML documentation generation. The default value is `false`. +### `disable-roslyn-reduce` + +**Type:** `boolean` + +Set to `true` to skip the Roslyn reduce (simplification) post-processing step. This speeds up generation and is useful when iterating quickly. The default value is `false`. + ### `generator-name` **Type:** `string` diff --git a/packages/http-client-csharp/emitter/src/emitter.ts b/packages/http-client-csharp/emitter/src/emitter.ts index 1aaa9c698f2..9df2a95330b 100644 --- a/packages/http-client-csharp/emitter/src/emitter.ts +++ b/packages/http-client-csharp/emitter/src/emitter.ts @@ -150,6 +150,8 @@ export function createConfiguration( "unreferenced-types-handling": options["unreferenced-types-handling"], "disable-xml-docs": options["disable-xml-docs"] === false ? undefined : options["disable-xml-docs"], + "disable-roslyn-reduce": + options["disable-roslyn-reduce"] === false ? undefined : options["disable-roslyn-reduce"], license: sdkContext.sdkPackage.licenseInfo, }; } diff --git a/packages/http-client-csharp/emitter/src/options.ts b/packages/http-client-csharp/emitter/src/options.ts index 9b9529c9ce2..952a756cf04 100644 --- a/packages/http-client-csharp/emitter/src/options.ts +++ b/packages/http-client-csharp/emitter/src/options.ts @@ -16,6 +16,7 @@ export interface CSharpEmitterOptions { debug?: boolean; logLevel?: LoggerLevel; "disable-xml-docs"?: boolean; + "disable-roslyn-reduce"?: boolean; "generator-name"?: string; "emitter-extension-path"?: string; plugins?: string[]; @@ -102,6 +103,13 @@ export const CSharpEmitterOptionsSchema: JSONSchemaType = description: "Set to `true` to disable XML documentation generation. The default value is `false`.", }, + "disable-roslyn-reduce": { + type: "boolean", + nullable: true, + description: + "Set to `true` to skip the Roslyn reduce (simplification) post-processing step. " + + "This speeds up generation and is useful when iterating quickly. The default value is `false`.", + }, "generator-name": { type: "string", nullable: true, diff --git a/packages/http-client-csharp/emitter/src/type/configuration.ts b/packages/http-client-csharp/emitter/src/type/configuration.ts index 1f7eaa03af7..2a2f3e2f2e8 100644 --- a/packages/http-client-csharp/emitter/src/type/configuration.ts +++ b/packages/http-client-csharp/emitter/src/type/configuration.ts @@ -5,6 +5,7 @@ export interface Configuration { "package-name": string | null; "unreferenced-types-handling"?: "removeOrInternalize" | "internalize" | "keepAll"; "disable-xml-docs"?: boolean; + "disable-roslyn-reduce"?: boolean; license?: { name: string; company?: string; diff --git a/packages/http-client-csharp/emitter/test/Unit/options.test.ts b/packages/http-client-csharp/emitter/test/Unit/options.test.ts index 2d82da0c25d..c5abbecc77b 100644 --- a/packages/http-client-csharp/emitter/test/Unit/options.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/options.test.ts @@ -125,6 +125,7 @@ describe("Configuration tests", async () => { "package-name": "custom-package", "unreferenced-types-handling": "removeOrInternalize", "disable-xml-docs": true, + "disable-roslyn-reduce": true, license: { name: "Custom License", company: "Custom Company", @@ -141,6 +142,7 @@ describe("Configuration tests", async () => { expect(config["package-name"]).toBe("custom-package"); expect(config["unreferenced-types-handling"]).toBe("removeOrInternalize"); expect(config["disable-xml-docs"]).toBe(true); + expect(config["disable-roslyn-reduce"]).toBe(true); expect(config.license).toEqual({ name: "Custom License", company: "Custom Company", diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs index d7cb00bf8b0..f1f79404b76 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs @@ -36,7 +36,8 @@ public Configuration( bool disableXmlDocs, UnreferencedTypesHandlingOption unreferencedTypesHandling, LicenseInfo? licenseInfo, - IReadOnlyList? pluginPaths = null) + IReadOnlyList? pluginPaths = null, + bool disableRoslynReduce = false) { OutputDirectory = outputPath; AdditionalConfigurationOptions = additionalConfigurationOptions; @@ -45,6 +46,7 @@ public Configuration( UnreferencedTypesHandling = unreferencedTypesHandling; LicenseInfo = licenseInfo; PluginPaths = pluginPaths; + DisableRoslynReduce = disableRoslynReduce; } /// @@ -54,6 +56,7 @@ private static class Options { public const string PackageName = "package-name"; public const string DisableXmlDocs = "disable-xml-docs"; + public const string DisableRoslynReduce = "disable-roslyn-reduce"; public const string UnreferencedTypesHandling = "unreferenced-types-handling"; public const string Plugins = "plugins"; } @@ -63,6 +66,13 @@ private static class Options /// public bool DisableXmlDocs { get; } + /// + /// Gets whether the Roslyn reduce (simplification) post-processing step is disabled. + /// Disabling it speeds up generation at the cost of less simplified output, which is + /// useful when iterating quickly. + /// + public bool DisableRoslynReduce { get; } + /// /// Gets the root output directory for the generated library. /// @@ -134,7 +144,8 @@ internal static Configuration Load(string outputPath, string? json = null) ReadOption(root, Options.DisableXmlDocs), ReadEnumOption(root, Options.UnreferencedTypesHandling), ReadLicenseInfo(root), - ReadStringArrayOption(root, Options.Plugins)); + ReadStringArrayOption(root, Options.Plugins), + ReadOption(root, Options.DisableRoslynReduce)); } private static LicenseInfo? ReadLicenseInfo(JsonElement root) @@ -165,6 +176,7 @@ internal static Configuration Load(string outputPath, string? json = null) private static readonly Dictionary _defaultBoolOptionValues = new() { { Options.DisableXmlDocs, false }, + { Options.DisableRoslynReduce, false }, }; /// @@ -174,6 +186,7 @@ internal static Configuration Load(string outputPath, string? json = null) { Options.PackageName, Options.DisableXmlDocs, + Options.DisableRoslynReduce, Options.UnreferencedTypesHandling, Options.Plugins, }; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs index d90488b4c85..4588b3c4839 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs @@ -148,7 +148,10 @@ private async Task ProcessDocument(Document document, MemberRemoverRew } document = document.WithSyntaxRoot(root); - document = await Simplifier.ReduceAsync(document); + if (!CodeModelGenerator.Instance.Configuration.DisableRoslynReduce) + { + document = await Simplifier.ReduceAsync(document); + } // Reformat if any custom rewriters have been applied if (CodeModelGenerator.Instance.Rewriters.Count > 0) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs index 1d81073459e..b0d402825e8 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/ConfigurationTests.cs @@ -242,6 +242,33 @@ public void DisableDocsForField() Assert.AreEqual("public int _field;\n", writer.ToString(false)); } + [Test] + public void DisableRoslynReduce_ParsedFromConfig() + { + var mockJson = @"{ + ""output-folder"": ""outputFolder"", + ""package-name"": ""libraryName"", + ""disable-roslyn-reduce"": true + }"; + + MockHelpers.LoadMockGenerator(configuration: mockJson); + + Assert.IsTrue(CodeModelGenerator.Instance.Configuration.DisableRoslynReduce); + } + + [Test] + public void DisableRoslynReduce_DefaultsToFalse() + { + var mockJson = @"{ + ""output-folder"": ""outputFolder"", + ""package-name"": ""libraryName"" + }"; + + MockHelpers.LoadMockGenerator(configuration: mockJson); + + Assert.IsFalse(CodeModelGenerator.Instance.Configuration.DisableRoslynReduce); + } + [Test] public void CanAddLicenseInfo() { diff --git a/packages/http-client-csharp/readme.md b/packages/http-client-csharp/readme.md index 2dba2aaa57b..ea48d690c25 100644 --- a/packages/http-client-csharp/readme.md +++ b/packages/http-client-csharp/readme.md @@ -113,6 +113,12 @@ Set the log level for which to collect traces. The default value is `info`. Set to `true` to disable XML documentation generation. The default value is `false`. +### `disable-roslyn-reduce` + +**Type:** `boolean` + +Set to `true` to skip the Roslyn reduce (simplification) post-processing step. This speeds up generation and is useful when iterating quickly. The default value is `false`. + ### `generator-name` **Type:** `string` diff --git a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md index e356043f01e..c3868941aa5 100644 --- a/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md +++ b/website/src/content/docs/docs/emitters/clients/http-client-csharp/reference/emitter.md @@ -96,6 +96,12 @@ Set the log level for which to collect traces. The default value is `info`. Set to `true` to disable XML documentation generation. The default value is `false`. +### `disable-roslyn-reduce` + +**Type:** `boolean` + +Set to `true` to skip the Roslyn reduce (simplification) post-processing step. This speeds up generation and is useful when iterating quickly. The default value is `false`. + ### `generator-name` **Type:** `string` From 3cf263877e89e236456f74cc0bcdae7d02ac62ae Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Jun 2026 19:55:27 +0000 Subject: [PATCH 19/29] [http-client-csharp] Expose extension point for custom-code attribute providers (#10981) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Derived C# generators (e.g. Azure management-plane) need to register generator-specific custom-code attributes such as `CodeGenResourceDataAttribute` that are emitted into generated SDK projects and available during custom-code compilation. The base generator's `CustomCodeAttributeProviders` list was not extensible, forcing downstream generators to use reflection. ## Changes - **`CodeModelGenerator.CustomCodeAttributeProviders`**: remains `internal`, now backed by a mutable list still pre-seeded with the four built-in definitions (`CodeGenType`/`Member`/`Suppress`/`Serialization`). - **`AddCustomCodeAttributeProvider(TypeProvider)`**: new `protected` method letting derived generators contribute their own attribute definitions. Registered providers flow through the existing `Configure()` → `AddTypeToKeep` path and into `OutputLibrary`/`CSharpGen` custom-code compilation — no reflection, no SDK dependency on the generator assembly. - **Tests**: - `GeneratorTests` cover the default provider count and appending via the new method (`TestGenerator` exposes the protected method for testing). - `ModelCustomizationTests.CanReadCustomCodeAttributeFromRegisteredProvider` is an end-to-end test that contributes a sample attribute provider through the extension point, references that attribute in TestData custom code on a partial model, emits the contributed definition into the custom-code compilation, and validates that the parsed `ModelProvider.CustomCodeView` registers the attribute (type, namespace, and argument count). Adds a `TestCustomCodeAttributeDefinition` helper and a TestData fixture. ## Usage ```csharp protected override void Configure() { base.Configure(); AddCustomCodeAttributeProvider(new CodeGenResourceDataAttributeDefinition()); } ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../src/CodeModelGenerator.cs | 19 +++++- .../test/GeneratorTests.cs | 20 ++++++ .../ModelProviders/ModelCustomizationTests.cs | 32 ++++++++++ .../MockInputModel.cs | 11 ++++ .../TestCustomCodeAttributeDefinition.cs | 62 +++++++++++++++++++ .../test/TestHelpers/TestGenerator.cs | 4 ++ 6 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs index c7a7574552b..3fa5cd8d5ca 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/CodeModelGenerator.cs @@ -99,7 +99,13 @@ internal set public IReadOnlyList SharedSourceDirectories => _sharedSourceDirectories; - internal IReadOnlyList CustomCodeAttributeProviders { get; } = + /// + /// The list of instances that define custom-code attributes. These attribute + /// definitions are generated into the SDK project and are made available to the compiler while it compiles + /// custom code. Derived generators can contribute additional providers via + /// . + /// + internal List CustomCodeAttributeProviders { get; } = [ new CodeGenTypeAttributeDefinition(), new CodeGenMemberAttributeDefinition(), @@ -160,6 +166,17 @@ public virtual void AddSharedSourceDirectory(string sharedSourceDirectory) _sharedSourceDirectories.Add(sharedSourceDirectory); } + /// + /// Adds a custom-code attribute provider that derived generators can use to contribute + /// generator-specific attribute definitions. The provider's attribute definition is generated into + /// the SDK project and made available to the compiler while it compiles custom code. + /// + /// The that defines the custom-code attribute. + protected void AddCustomCodeAttributeProvider(TypeProvider provider) + { + CustomCodeAttributeProviders.Add(provider); + } + private record KeptTypesInfo(HashSet TypeNames, HashSet TypeProviders); private readonly KeptTypesInfo _additionalRootTypeInfo = new([], []); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs index bced881740b..33c81f262c9 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/GeneratorTests.cs @@ -100,6 +100,26 @@ public void RemoveVisitorByNameRemovesAllMatchingInstances() Assert.IsInstanceOf(mockGenerator.Visitors[0]); } + [Test] + public void HasDefaultCustomCodeAttributeProviders() + { + var mockGenerator = new TestGenerator(); + Assert.AreEqual(4, mockGenerator.CustomCodeAttributeProviders.Count); + } + + [Test] + public void CanAddCustomCodeAttributeProvider() + { + var mockGenerator = new TestGenerator(); + var initialCount = mockGenerator.CustomCodeAttributeProviders.Count; + + var provider = new TestTypeProvider(); + mockGenerator.AddCustomCodeAttributeProviderForTest(provider); + + Assert.AreEqual(initialCount + 1, mockGenerator.CustomCodeAttributeProviders.Count); + Assert.AreSame(provider, mockGenerator.CustomCodeAttributeProviders[^1]); + } + private class DerivedTestLibraryVisitor : TestLibraryVisitor { } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs index 5cdc9161163..9033ed9b667 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs @@ -1815,6 +1815,38 @@ public async Task CanReadPropertyAttributes() Assert.AreEqual(1, fieldObsoleteAttr.Arguments.Count); } + [Test] + public async Task CanReadCustomCodeAttributeFromRegisteredProvider() + { + // A derived generator contributes a generator-specific custom-code attribute via the extension point. + var customAttributeProvider = new TestCustomCodeAttributeDefinition(); + var generator = new TestGenerator(); + generator.AddCustomCodeAttributeProviderForTest(customAttributeProvider); + CollectionAssert.Contains(generator.CustomCodeAttributeProviders, customAttributeProvider); + + await MockHelpers.LoadMockGeneratorAsync( + compilation: async () => + { + var compilation = await Helpers.GetCompilationFromDirectoryAsync(); + // Mirror CSharpGen: the contributed attribute definition is emitted into the custom-code + // compilation so that custom code referencing it compiles and can be parsed. + return compilation.AddSyntaxTrees(GeneratedCodeWorkspace.GetTree(customAttributeProvider)); + }); + + var inputModel = InputFactory.Model("mockInputModel"); + var modelProvider = new ModelProvider(inputModel); + var customCodeView = modelProvider.CustomCodeView; + + Assert.IsNotNull(customCodeView); + + // Validate that the parsed type registers the custom-code attribute contributed by the provider. + var customAttr = customCodeView!.Attributes.Single(a => a.Type.Name == "CodeGenCustomAttribute"); + Assert.AreEqual(AttributeNamespace, customAttr.Type.Namespace); + Assert.AreEqual(1, customAttr.Arguments.Count); + } + + private const string AttributeNamespace = TestCustomCodeAttributeDefinition.AttributeNamespace; + private class TestNameVisitor : NameVisitor { public TypeProvider? InvokeVisit(TypeProvider type) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs new file mode 100644 index 00000000000..fcc78cfc9a6 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanReadCustomCodeAttributeFromRegisteredProvider/MockInputModel.cs @@ -0,0 +1,11 @@ +#nullable disable + +using Sample.Customizations; + +namespace Sample.Models +{ + [CodeGenCustom("CustomValue")] + public partial class MockInputModel + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs new file mode 100644 index 00000000000..fc7733324bc --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestCustomCodeAttributeDefinition.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.TypeSpec.Generator.Primitives; +using Microsoft.TypeSpec.Generator.Providers; +using Microsoft.TypeSpec.Generator.Statements; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.Tests +{ + /// + /// A sample generator-specific custom-code attribute definition that a derived generator could contribute + /// via AddCustomCodeAttributeProvider. Used to validate that custom code referencing the attribute is + /// parsed and the attribute is registered on the parsed type. + /// + public class TestCustomCodeAttributeDefinition : TypeProvider + { + public const string AttributeNamespace = "Sample.Customizations"; + + protected override string BuildRelativeFilePath() => Path.Combine("src", "Generated", "Internal", $"{Name}.cs"); + + protected override string BuildName() => "CodeGenCustomAttribute"; + + protected override string BuildNamespace() => AttributeNamespace; + + protected override TypeSignatureModifiers BuildDeclarationModifiers() => + TypeSignatureModifiers.Public | TypeSignatureModifiers.Class; + + protected internal override CSharpType[] BuildImplements() => [typeof(Attribute)]; + + protected internal override PropertyProvider[] BuildProperties() => + [ + new PropertyProvider( + null, + MethodSignatureModifiers.Public, + typeof(string), + "Value", + new AutoPropertyBody(false), + this) + ]; + + protected internal override ConstructorProvider[] BuildConstructors() + { + var parameter = new ParameterProvider("value", $"The custom value.", typeof(string)); + + return + [ + new ConstructorProvider( + new ConstructorSignature( + Type, + null, + MethodSignatureModifiers.Public, + [parameter]), + This.Property("Value").Assign(parameter).Terminate(), + this) + ]; + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs index a96c2c3b3a2..ba191712d0b 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/TestHelpers/TestGenerator.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System.Collections.Generic; +using Microsoft.TypeSpec.Generator.Providers; namespace Microsoft.TypeSpec.Generator.Tests { @@ -10,5 +11,8 @@ public class TestGenerator : CodeModelGenerator public TestGenerator() { } + + public void AddCustomCodeAttributeProviderForTest(TypeProvider provider) + => AddCustomCodeAttributeProvider(provider); } } From 3a86d4e55d411d5fa0da585212a6013477946032 Mon Sep 17 00:00:00 2001 From: jenny <63012604+JennyPng@users.noreply.github.com> Date: Fri, 12 Jun 2026 13:32:49 -0700 Subject: [PATCH 20/29] [python] Refactor Python emitter node imports to be browser bundleable (#10844) - after polyfill plugin was removed, Python emitter is no longer browser bundleable due to Node or filesystem imports - extract Node calls into a separate file and swap for browser vs. non-browser local validation: - Works in browser: from the `typespec-azure` repo, overrode and installed this branch's http-client-python and checked that `/typespec-azure-playground-website` is able to start when including `typespec-python` --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- ...r-node-python-emitter-2026-5-3-15-23-59.md | 7 + .../http-client-python/emitter/src/emitter.ts | 197 +--------------- .../emitter/src/node-runner.browser.ts | 33 +++ .../emitter/src/node-runner.ts | 220 ++++++++++++++++++ .../emitter/src/pyodide-loader.browser.ts | 49 ++++ .../emitter/src/pyodide-loader.ts | 6 + packages/http-client-python/package.json | 4 + 7 files changed, 328 insertions(+), 188 deletions(-) create mode 100644 .chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md create mode 100644 packages/http-client-python/emitter/src/node-runner.browser.ts create mode 100644 packages/http-client-python/emitter/src/node-runner.ts create mode 100644 packages/http-client-python/emitter/src/pyodide-loader.browser.ts create mode 100644 packages/http-client-python/emitter/src/pyodide-loader.ts diff --git a/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md b/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md new file mode 100644 index 00000000000..1d679fb8619 --- /dev/null +++ b/.chronus/changes/refactor-node-python-emitter-2026-5-3-15-23-59.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Refactor Node usage in Python emitter to make it browser bundleable \ No newline at end of file diff --git a/packages/http-client-python/emitter/src/emitter.ts b/packages/http-client-python/emitter/src/emitter.ts index 3ecd85c5f57..0208795e024 100644 --- a/packages/http-client-python/emitter/src/emitter.ts +++ b/packages/http-client-python/emitter/src/emitter.ts @@ -1,24 +1,17 @@ import { createSdkContext } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, emitFile, joinPaths, NoTarget } from "@typespec/compiler"; -import { execSync } from "child_process"; -import fs from "fs"; import jsyaml from "js-yaml"; -import os from "os"; -import path, { dirname } from "path"; -import { loadPyodide, PyodideInterface } from "pyodide"; -import { fileURLToPath } from "url"; import pkgJson from "../../package.json" with { type: "json" }; import { emitCodeModel } from "./code-model.js"; import { - blackExcludeDirs, BLOB_STORAGE_BASE_URL, PACKAGE_NAME, PYGEN_WHEEL_FILENAME, PYODIDE_VERSION, } from "./constants.js"; -import { saveCodeModelAsYaml } from "./external-process.js"; import { PythonEmitterOptions, PythonSdkContext, reportDiagnostic } from "./lib.js"; -import { runPython3 } from "./run-python3.js"; +import { runNodeEmit } from "./node-runner.js"; +import { loadPyodide, PyodideInterface } from "./pyodide-loader.js"; import { getRootNamespace, md2Rst } from "./utils.js"; function getBrowserPygenWheelUrl(): string { @@ -193,7 +186,6 @@ async function onEmitMain(context: EmitContext) { const program = context.program; const sdkContext = await createPythonSdkContext(context); - const outputDir = context.emitterOutputDir; addDefaultOptions(sdkContext); const yamlMap = emitCodeModel(sdkContext); const parsedYamlMap = walkThroughNodes(yamlMap); @@ -255,83 +247,13 @@ async function onEmitMain(context: EmitContext) { await runPyodideGeneration(pyodide, "/output", yamlFilePath, commandArgs); await copyPyodideOutputToHost(context, pyodide, "/output"); } else { - const root = path.join(dirname(fileURLToPath(import.meta.url)), "..", ".."); - const yamlPath = await saveCodeModelAsYaml("python-yaml-path", parsedYamlMap); - - if (!program.compilerOptions.noEmit && !program.hasError()) { - // If emit-yaml-only mode, just copy YAML to output dir for batch processing - if (resolvedOptions["emit-yaml-only"]) { - if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir, { recursive: true }); - } - // Copy YAML to output dir with command args embedded - // Use unique filename to avoid conflicts when multiple specs share output dir - const configId = path.basename(yamlPath, ".yaml"); - const batchConfig = { yamlPath, commandArgs, outputDir }; - fs.writeFileSync( - path.join(outputDir, `.tsp-codegen-${configId}.json`), - JSON.stringify(batchConfig, null, 2), - ); - return; - } - // if not using pyodide and there's no venv, we try to create venv - if (!resolvedOptions["use-pyodide"] && !fs.existsSync(path.join(root, "venv"))) { - try { - await runPython3(path.join(root, "/eng/scripts/setup/install.py")); - await runPython3(path.join(root, "/eng/scripts/setup/prepare.py")); - } catch { - // if the python env is not ready, we use pyodide instead - resolvedOptions["use-pyodide"] = true; - } - } - - if (resolvedOptions["use-pyodide"]) { - // here we run with pyodide - const pyodide = await setupPyodideCall(root); - // create the output folder if not exists - if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir, { recursive: true }); - } - // mount output folder to pyodide - pyodide.FS.mkdirTree("/output"); - pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: outputDir }, "/output"); - // mount yaml file to pyodide - pyodide.FS.mkdirTree("/yaml"); - pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: path.dirname(yamlPath) }, "/yaml"); - await runPyodideGeneration( - pyodide, - "/output", - `/yaml/${path.basename(yamlPath)}`, - commandArgs, - ); - } else { - // here we run with native python - let venvPath = path.join(root, "venv"); - if (fs.existsSync(path.join(venvPath, "bin"))) { - venvPath = path.join(venvPath, "bin", "python"); - } else if (fs.existsSync(path.join(venvPath, "Scripts"))) { - venvPath = path.join(venvPath, "Scripts", "python.exe"); - } else { - reportDiagnostic(program, { - code: "pyodide-flag-conflict", - target: NoTarget, - }); - } - commandArgs["output-folder"] = outputDir; - commandArgs["tsp-file"] = yamlPath; - const commandFlags = Object.entries(commandArgs) - .map(([key, value]) => `--${key}=${value}`) - .join(" "); - const command = `${venvPath} ${root}/eng/scripts/setup/run_tsp.py ${commandFlags}`; - execSync(command); - - const excludePattern = blackExcludeDirs.join("|"); - execSync( - `${venvPath} -m black --line-length=120 --quiet --fast ${outputDir} --exclude "${excludePattern}"`, - ); - await checkForPylintIssues(outputDir, excludePattern); - } - } + await runNodeEmit({ + context, + parsedYamlMap, + commandArgs, + resolvedOptions, + runPyodideGeneration, + }); } } @@ -367,104 +289,3 @@ async function setupPyodideCallBrowser() { return pyodide; } - -async function setupPyodideCall(root: string) { - const pyodide = await loadPyodide({ - indexURL: path.dirname(fileURLToPath(import.meta.resolve("pyodide"))), - }); - const micropipLockPath = path.join(root, "micropip.lock"); - while (true) { - if (fs.existsSync(micropipLockPath)) { - try { - const stats = fs.statSync(micropipLockPath); - const now = new Date().getTime(); - const lockAge = (now - stats.mtime.getTime()) / 1000; - if (lockAge > 300) { - fs.unlinkSync(micropipLockPath); - } - } catch { - // ignore - } - } - try { - const fd = fs.openSync(micropipLockPath, "wx"); - // mount generator to pyodide - pyodide.FS.mkdirTree("/generator"); - pyodide.FS.mount( - pyodide.FS.filesystems.NODEFS, - { root: path.join(root, "generator") }, - "/generator", - ); - await pyodide.loadPackage("micropip"); - const micropip = pyodide.pyimport("micropip"); - await micropip.install(`emfs:/generator/dist/${PYGEN_WHEEL_FILENAME}`); - fs.closeSync(fd); - fs.unlinkSync(micropipLockPath); - break; - } catch { - await new Promise((resolve) => setTimeout(resolve, 1000)); - } - } - return pyodide; -} - -async function checkForPylintIssues(outputDir: string, excludePattern: string) { - const excludeRegex = new RegExp(excludePattern); - - const shouldExcludePath = (filePath: string): boolean => { - const relativePath = path.relative(outputDir, filePath); - const normalizedPath = relativePath.replace(/\\/g, "/"); - return excludeRegex.test(normalizedPath); - }; - - const processFile = async (filePath: string) => { - let fileContent = await fs.promises.readFile(filePath, "utf-8"); - const pylintDisables: string[] = []; - const lineEnding = fileContent.includes("\r\n") && os.platform() === "win32" ? "\r\n" : "\n"; - const lines: string[] = fileContent.split(lineEnding); - if (lines.length > 0) { - if (!lines[0].includes("line-too-long") && lines.some((line) => line.length > 120)) { - pylintDisables.push("line-too-long", "useless-suppression"); - } - if (!lines[0].includes("too-many-lines") && lines.length > 1000) { - pylintDisables.push("too-many-lines"); - } - if (pylintDisables.length > 0) { - fileContent = lines[0].includes("pylint: disable=") - ? [lines[0] + "," + pylintDisables.join(",")].concat(lines.slice(1)).join(lineEnding) - : `# pylint: disable=${pylintDisables.join(",")}${lineEnding}` + fileContent; - await fs.promises.writeFile(filePath, fileContent); - } - } - }; - - const collectPythonFiles = async (dir: string): Promise => { - if (shouldExcludePath(dir)) { - return []; - } - - const entries = await fs.promises.readdir(dir, { withFileTypes: true }); - - const promises = entries.map(async (entry) => { - const filePath = path.join(dir, entry.name); - - if (shouldExcludePath(filePath)) { - return []; - } - - if (entry.isDirectory()) { - return collectPythonFiles(filePath); - } else if (entry.name.endsWith(".py")) { - return [filePath]; - } - return []; - }); - - const results = await Promise.all(promises); - return results.flat(); - }; - - // Collect all Python files first, then process in parallel - const pythonFiles = await collectPythonFiles(outputDir); - await Promise.all(pythonFiles.map(processFile)); -} diff --git a/packages/http-client-python/emitter/src/node-runner.browser.ts b/packages/http-client-python/emitter/src/node-runner.browser.ts new file mode 100644 index 00000000000..bc548efdf8a --- /dev/null +++ b/packages/http-client-python/emitter/src/node-runner.browser.ts @@ -0,0 +1,33 @@ +// Browser stub for `node-runner.ts`. Swapped in via the `"browser"` field in +// `package.json`. The emitter's browser flow short-circuits before reaching +// `runNodeEmit`, so this stub is defense-in-depth — if it does get called, +// surface a clear diagnostic rather than a cryptic missing-module error. + +import type { EmitContext } from "@typespec/compiler"; +import { NoTarget } from "@typespec/compiler"; +import type { PyodideInterface } from "pyodide"; +import { PythonEmitterOptions, reportDiagnostic } from "./lib.js"; + +export interface RunNodeEmitArgs { + context: EmitContext; + parsedYamlMap: Record; + commandArgs: Record; + resolvedOptions: PythonEmitterOptions; + runPyodideGeneration: ( + pyodide: PyodideInterface, + outputFolder: string, + yamlFile: string, + commandArgs: Record, + ) => Promise; +} + +export async function runNodeEmit({ context }: RunNodeEmitArgs): Promise { + reportDiagnostic(context.program, { + code: "browser-runtime-load-failed", + target: NoTarget, + format: { + details: + "Native Python execution is not supported in the browser; the emitter must run in the in-browser Pyodide branch.", + }, + }); +} diff --git a/packages/http-client-python/emitter/src/node-runner.ts b/packages/http-client-python/emitter/src/node-runner.ts new file mode 100644 index 00000000000..47af1553517 --- /dev/null +++ b/packages/http-client-python/emitter/src/node-runner.ts @@ -0,0 +1,220 @@ +// Node-only execution path for the Python emitter. +// +// All direct usage of Node built-ins (`fs`, `os`, `path`, `url`, `child_process`) +// lives here so that the emitter entry can be bundled for the browser. A sibling +// `node-runner.browser.ts` stub is swapped in via the `"browser"` field in +// `package.json` when bundling with `platform: "browser"`. + +import { EmitContext, NoTarget } from "@typespec/compiler"; +import { execSync } from "child_process"; +import fs from "fs"; +import os from "os"; +import path, { dirname } from "path"; +import { loadPyodide, PyodideInterface } from "pyodide"; +import { fileURLToPath } from "url"; +import { blackExcludeDirs, PYGEN_WHEEL_FILENAME } from "./constants.js"; +import { saveCodeModelAsYaml } from "./external-process.js"; +import { PythonEmitterOptions, reportDiagnostic } from "./lib.js"; +import { runPython3 } from "./run-python3.js"; + +export interface RunNodeEmitArgs { + context: EmitContext; + parsedYamlMap: Record; + commandArgs: Record; + resolvedOptions: PythonEmitterOptions; + runPyodideGeneration: ( + pyodide: PyodideInterface, + outputFolder: string, + yamlFile: string, + commandArgs: Record, + ) => Promise; +} + +export async function runNodeEmit({ + context, + parsedYamlMap, + commandArgs, + resolvedOptions, + runPyodideGeneration, +}: RunNodeEmitArgs): Promise { + const program = context.program; + const outputDir = context.emitterOutputDir; + const root = path.join(dirname(fileURLToPath(import.meta.url)), "..", ".."); + const yamlPath = await saveCodeModelAsYaml("python-yaml-path", parsedYamlMap); + + if (program.compilerOptions.noEmit || program.hasError()) { + return; + } + + // If emit-yaml-only mode, just copy YAML to output dir for batch processing + if (resolvedOptions["emit-yaml-only"]) { + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir, { recursive: true }); + } + // Copy YAML to output dir with command args embedded + // Use unique filename to avoid conflicts when multiple specs share output dir + const configId = path.basename(yamlPath, ".yaml"); + const batchConfig = { yamlPath, commandArgs, outputDir }; + fs.writeFileSync( + path.join(outputDir, `.tsp-codegen-${configId}.json`), + JSON.stringify(batchConfig, null, 2), + ); + return; + } + + // if not using pyodide and there's no venv, we try to create venv + if (!resolvedOptions["use-pyodide"] && !fs.existsSync(path.join(root, "venv"))) { + try { + await runPython3(path.join(root, "/eng/scripts/setup/install.py")); + await runPython3(path.join(root, "/eng/scripts/setup/prepare.py")); + } catch { + // if the python env is not ready, we use pyodide instead + resolvedOptions["use-pyodide"] = true; + } + } + + if (resolvedOptions["use-pyodide"]) { + // here we run with pyodide + const pyodide = await setupPyodideCall(root); + // create the output folder if not exists + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir, { recursive: true }); + } + // mount output folder to pyodide + pyodide.FS.mkdirTree("/output"); + pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: outputDir }, "/output"); + // mount yaml file to pyodide + pyodide.FS.mkdirTree("/yaml"); + pyodide.FS.mount(pyodide.FS.filesystems.NODEFS, { root: path.dirname(yamlPath) }, "/yaml"); + await runPyodideGeneration(pyodide, "/output", `/yaml/${path.basename(yamlPath)}`, commandArgs); + return; + } + + // here we run with native python + let venvPath = path.join(root, "venv"); + if (fs.existsSync(path.join(venvPath, "bin"))) { + venvPath = path.join(venvPath, "bin", "python"); + } else if (fs.existsSync(path.join(venvPath, "Scripts"))) { + venvPath = path.join(venvPath, "Scripts", "python.exe"); + } else { + reportDiagnostic(program, { + code: "pyodide-flag-conflict", + target: NoTarget, + }); + return; + } + commandArgs["output-folder"] = outputDir; + commandArgs["tsp-file"] = yamlPath; + const commandFlags = Object.entries(commandArgs) + .map(([key, value]) => `--${key}=${value}`) + .join(" "); + const command = `${venvPath} ${root}/eng/scripts/setup/run_tsp.py ${commandFlags}`; + execSync(command); + + const excludePattern = blackExcludeDirs.join("|"); + execSync( + `${venvPath} -m black --line-length=120 --quiet --fast ${outputDir} --exclude "${excludePattern}"`, + ); + await checkForPylintIssues(outputDir, excludePattern); +} + +async function setupPyodideCall(root: string): Promise { + const pyodide = await loadPyodide({ + indexURL: path.dirname(fileURLToPath(import.meta.resolve("pyodide"))), + }); + const micropipLockPath = path.join(root, "micropip.lock"); + while (true) { + if (fs.existsSync(micropipLockPath)) { + try { + const stats = fs.statSync(micropipLockPath); + const now = new Date().getTime(); + const lockAge = (now - stats.mtime.getTime()) / 1000; + if (lockAge > 300) { + fs.unlinkSync(micropipLockPath); + } + } catch { + // ignore + } + } + try { + const fd = fs.openSync(micropipLockPath, "wx"); + // mount generator to pyodide + pyodide.FS.mkdirTree("/generator"); + pyodide.FS.mount( + pyodide.FS.filesystems.NODEFS, + { root: path.join(root, "generator") }, + "/generator", + ); + await pyodide.loadPackage("micropip"); + const micropip = pyodide.pyimport("micropip"); + await micropip.install(`emfs:/generator/dist/${PYGEN_WHEEL_FILENAME}`); + fs.closeSync(fd); + fs.unlinkSync(micropipLockPath); + break; + } catch { + await new Promise((resolve) => setTimeout(resolve, 1000)); + } + } + return pyodide; +} + +async function checkForPylintIssues(outputDir: string, excludePattern: string) { + const excludeRegex = new RegExp(excludePattern); + + const shouldExcludePath = (filePath: string): boolean => { + const relativePath = path.relative(outputDir, filePath); + const normalizedPath = relativePath.replace(/\\/g, "/"); + return excludeRegex.test(normalizedPath); + }; + + const processFile = async (filePath: string) => { + let fileContent = await fs.promises.readFile(filePath, "utf-8"); + const pylintDisables: string[] = []; + const lineEnding = fileContent.includes("\r\n") && os.platform() === "win32" ? "\r\n" : "\n"; + const lines: string[] = fileContent.split(lineEnding); + if (lines.length > 0) { + if (!lines[0].includes("line-too-long") && lines.some((line) => line.length > 120)) { + pylintDisables.push("line-too-long", "useless-suppression"); + } + if (!lines[0].includes("too-many-lines") && lines.length > 1000) { + pylintDisables.push("too-many-lines"); + } + if (pylintDisables.length > 0) { + fileContent = lines[0].includes("pylint: disable=") + ? [lines[0] + "," + pylintDisables.join(",")].concat(lines.slice(1)).join(lineEnding) + : `# pylint: disable=${pylintDisables.join(",")}${lineEnding}` + fileContent; + await fs.promises.writeFile(filePath, fileContent); + } + } + }; + + const collectPythonFiles = async (dir: string): Promise => { + if (shouldExcludePath(dir)) { + return []; + } + + const entries = await fs.promises.readdir(dir, { withFileTypes: true }); + + const promises = entries.map(async (entry) => { + const filePath = path.join(dir, entry.name); + + if (shouldExcludePath(filePath)) { + return []; + } + + if (entry.isDirectory()) { + return collectPythonFiles(filePath); + } else if (entry.name.endsWith(".py")) { + return [filePath]; + } + return []; + }); + + const results = await Promise.all(promises); + return results.flat(); + }; + + // Collect all Python files first, then process in parallel + const pythonFiles = await collectPythonFiles(outputDir); + await Promise.all(pythonFiles.map(processFile)); +} diff --git a/packages/http-client-python/emitter/src/pyodide-loader.browser.ts b/packages/http-client-python/emitter/src/pyodide-loader.browser.ts new file mode 100644 index 00000000000..e0a7cde43e8 --- /dev/null +++ b/packages/http-client-python/emitter/src/pyodide-loader.browser.ts @@ -0,0 +1,49 @@ +// Browser stub for `pyodide-loader.ts`. Loads pyodide via a `