Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/upgrade_spector-2025-7-19-11-51-56.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: dependencies
packages:
- "@azure-tools/typespec-python"
---

Upgrade azure-http-specs version.
4 changes: 2 additions & 2 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@azure-tools/typespec-azure-rulesets": "~0.59.0",
"@azure-tools/typespec-autorest": "~0.59.0",
"@azure-tools/typespec-client-generator-core": "~0.59.0",
"@azure-tools/azure-http-specs": "0.1.0-alpha.25",
"@azure-tools/azure-http-specs": "0.1.0-alpha.27",
"@typespec/http-specs": "0.1.0-alpha.25",
"@typespec/spector": "0.1.0-alpha.17",
"@typespec/spec-api": "0.1.0-alpha.8",
Expand All @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"client.naming.models.PythonModel": "Client.Naming.Model.ModelWithLanguageClientName",
"client.naming.models.ClientExtensibleEnum": "Client.Naming.UnionEnum.ServerExtensibleEnum",
"client.naming.models.ExtensibleEnum": "Client.Naming.UnionEnum.ExtensibleEnum",
"client.naming.operations.ClientModelOperations.client": "Client.Naming.Model.client",
"client.naming.aio.operations.ClientModelOperations.client": "Client.Naming.Model.client",
"client.naming.operations.ClientModelOperations.language": "Client.Naming.Model.language",
"client.naming.aio.operations.ClientModelOperations.language": "Client.Naming.Model.language",
"client.naming.operations.ModelClientOperations.client": "Client.Naming.Model.client",
"client.naming.aio.operations.ModelClientOperations.client": "Client.Naming.Model.client",
"client.naming.operations.ModelClientOperations.language": "Client.Naming.Model.language",
"client.naming.aio.operations.ModelClientOperations.language": "Client.Naming.Model.language",
"client.naming.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName",
"client.naming.aio.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName",
"client.naming.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

from ._configuration import NamingClientConfiguration
from ._utils.serialization import Deserializer, Serializer
from .operations import ClientModelOperations, UnionEnumOperations, _NamingClientOperationsMixin
from .operations import ModelClientOperations, UnionEnumOperations, _NamingClientOperationsMixin


class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""Describe changing names of types in a client with ``@clientName``.

:ivar client_model: ClientModelOperations operations
:vartype client_model: client.naming.operations.ClientModelOperations
:ivar model_client: ModelClientOperations operations
:vartype model_client: client.naming.operations.ModelClientOperations
:ivar union_enum: UnionEnumOperations operations
:vartype union_enum: client.naming.operations.UnionEnumOperations
:keyword endpoint: Service host. Default value is "http://localhost:3000".
Expand Down Expand Up @@ -58,7 +58,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
self.client_model = ClientModelOperations(self._client, self._config, self._serialize, self._deserialize)
self.model_client = ModelClientOperations(self._client, self._config, self._serialize, self._deserialize)
self.union_enum = UnionEnumOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

from .._utils.serialization import Deserializer, Serializer
from ._configuration import NamingClientConfiguration
from .operations import ClientModelOperations, UnionEnumOperations, _NamingClientOperationsMixin
from .operations import ModelClientOperations, UnionEnumOperations, _NamingClientOperationsMixin


class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""Describe changing names of types in a client with ``@clientName``.

:ivar client_model: ClientModelOperations operations
:vartype client_model: client.naming.aio.operations.ClientModelOperations
:ivar model_client: ModelClientOperations operations
:vartype model_client: client.naming.aio.operations.ModelClientOperations
:ivar union_enum: UnionEnumOperations operations
:vartype union_enum: client.naming.aio.operations.UnionEnumOperations
:keyword endpoint: Service host. Default value is "http://localhost:3000".
Expand Down Expand Up @@ -58,7 +58,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
self.client_model = ClientModelOperations(self._client, self._config, self._serialize, self._deserialize)
self.model_client = ModelClientOperations(self._client, self._config, self._serialize, self._deserialize)
self.union_enum = UnionEnumOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._operations import ClientModelOperations # type: ignore
from ._operations import ModelClientOperations # type: ignore
from ._operations import UnionEnumOperations # type: ignore
from ._operations import _NamingClientOperationsMixin # type: ignore # pylint: disable=unused-import

Expand All @@ -21,7 +21,7 @@
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ClientModelOperations",
"ModelClientOperations",
"UnionEnumOperations",
]
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from ..._utils.serialization import Deserializer, Serializer
from ..._utils.utils import ClientMixinABC
from ...operations._operations import (
build_client_model_client_request,
build_client_model_language_request,
build_model_client_client_request,
build_model_client_language_request,
build_naming_client_name_request,
build_naming_client_request,
build_naming_compatible_with_encoded_name_request,
Expand All @@ -49,14 +49,14 @@
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]


class ClientModelOperations:
class ModelClientOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.

Instead, you should access the following operations through
:class:`~client.naming.aio.NamingClient`'s
:attr:`client_model` attribute.
:attr:`model_client` attribute.
"""

def __init__(self, *args, **kwargs) -> None:
Expand Down Expand Up @@ -139,7 +139,7 @@ async def client(self, body: Union[_models.ClientModel, JSON, IO[bytes]], **kwar
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_client_model_client_request(
_request = build_model_client_client_request(
content_type=content_type,
content=_content,
headers=_headers,
Expand Down Expand Up @@ -239,7 +239,7 @@ async def language(self, body: Union[_models.PythonModel, JSON, IO[bytes]], **kw
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_client_model_language_request(
_request = build_model_client_language_request(
content_type=content_type,
content=_content,
headers=_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._operations import ClientModelOperations # type: ignore
from ._operations import ModelClientOperations # type: ignore
from ._operations import UnionEnumOperations # type: ignore
from ._operations import _NamingClientOperationsMixin # type: ignore # pylint: disable=unused-import

Expand All @@ -21,7 +21,7 @@
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ClientModelOperations",
"ModelClientOperations",
"UnionEnumOperations",
]
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
_SERIALIZER.client_side_validation = False


def build_client_model_client_request(**kwargs: Any) -> HttpRequest:
def build_model_client_client_request(**kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
Expand All @@ -53,7 +53,7 @@ def build_client_model_client_request(**kwargs: Any) -> HttpRequest:
return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)


def build_client_model_language_request(**kwargs: Any) -> HttpRequest:
def build_model_client_language_request(**kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
Expand Down Expand Up @@ -173,14 +173,14 @@ def build_naming_response_request(**kwargs: Any) -> HttpRequest:
return HttpRequest(method="GET", url=_url, **kwargs)


class ClientModelOperations:
class ModelClientOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.

Instead, you should access the following operations through
:class:`~client.naming.NamingClient`'s
:attr:`client_model` attribute.
:attr:`model_client` attribute.
"""

def __init__(self, *args, **kwargs) -> None:
Expand Down Expand Up @@ -265,7 +265,7 @@ def client( # pylint: disable=inconsistent-return-statements
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_client_model_client_request(
_request = build_model_client_client_request(
content_type=content_type,
content=_content,
headers=_headers,
Expand Down Expand Up @@ -365,7 +365,7 @@ def language( # pylint: disable=inconsistent-return-statements
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_client_model_language_request(
_request = build_model_client_language_request(
content_type=content_type,
content=_content,
headers=_headers,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils import recorded_by_proxy
from testpreparer import NamingClientTestBase, NamingPreparer


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestNamingModelClientOperations(NamingClientTestBase):
@NamingPreparer()
@recorded_by_proxy
def test_model_client_client(self, naming_endpoint):
client = self.create_client(endpoint=naming_endpoint)
response = client.model_client.client(
body={"defaultName": bool},
)

# please add some check logic here by yourself
# ...

@NamingPreparer()
@recorded_by_proxy
def test_model_client_language(self, naming_endpoint):
client = self.create_client(endpoint=naming_endpoint)
response = client.model_client.language(
body={"defaultName": bool},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils.aio import recorded_by_proxy_async
from testpreparer import NamingPreparer
from testpreparer_async import NamingClientTestBaseAsync


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestNamingModelClientOperationsAsync(NamingClientTestBaseAsync):
@NamingPreparer()
@recorded_by_proxy_async
async def test_model_client_client(self, naming_endpoint):
client = self.create_async_client(endpoint=naming_endpoint)
response = await client.model_client.client(
body={"defaultName": bool},
)

# please add some check logic here by yourself
# ...

@NamingPreparer()
@recorded_by_proxy_async
async def test_model_client_language(self, naming_endpoint):
client = self.create_async_client(endpoint=naming_endpoint)
response = await client.model_client.language(
body={"defaultName": bool},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ async def test_header_response(client: NamingClient):

@pytest.mark.asyncio
async def test_model_client(client: NamingClient):
await client.client_model.client(models.ClientModel(default_name=True))
await client.model_client.client(models.ClientModel(default_name=True))


@pytest.mark.asyncio
async def test_model_language(client: NamingClient):
await client.client_model.language(models.PythonModel(default_name=True))
await client.model_client.language(models.PythonModel(default_name=True))


@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def test_header_response(client: NamingClient):


def test_model_client(client: NamingClient):
client.client_model.client(models.ClientModel(default_name=True))
client.model_client.client(models.ClientModel(default_name=True))


def test_model_language(client: NamingClient):
client.client_model.language(models.PythonModel(default_name=True))
client.model_client.language(models.PythonModel(default_name=True))


def test_union_enum_member_name(client: NamingClient):
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading