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
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM4Nzg0Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM5NjI0NS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM4Nzg0Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM5NjI0NS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand All @@ -86,7 +86,7 @@
"@azure-tools/typespec-azure-rulesets": "~0.60.0",
"@azure-tools/typespec-autorest": "~0.60.0",
"@azure-tools/typespec-client-generator-core": "~0.60.2",
"@azure-tools/azure-http-specs": "0.1.0-alpha.29",
"@azure-tools/azure-http-specs": "0.1.0-alpha.30-dev.5",
"@typespec/http-specs": "0.1.0-alpha.26",
"@typespec/spector": "0.1.0-alpha.18",
"@typespec/spec-api": "0.1.0-alpha.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"specs.azure.clientgenerator.core.override.operations.ReorderParametersOperations.reorder": "_Specs_.Azure.ClientGenerator.Core.Override.ReorderParameters.reorder",
"specs.azure.clientgenerator.core.override.aio.operations.ReorderParametersOperations.reorder": "_Specs_.Azure.ClientGenerator.Core.Override.ReorderParameters.reorder",
"specs.azure.clientgenerator.core.override.operations.GroupParametersOperations.group": "_Specs_.Azure.ClientGenerator.Core.Override.GroupParameters.group",
"specs.azure.clientgenerator.core.override.aio.operations.GroupParametersOperations.group": "_Specs_.Azure.ClientGenerator.Core.Override.GroupParameters.group"
"specs.azure.clientgenerator.core.override.aio.operations.GroupParametersOperations.group": "_Specs_.Azure.ClientGenerator.Core.Override.GroupParameters.group",
"specs.azure.clientgenerator.core.override.operations.RequireOptionalParameterOperations.require_optional": "_Specs_.Azure.ClientGenerator.Core.Override.RequireOptionalParameter.requireOptional",
"specs.azure.clientgenerator.core.override.aio.operations.RequireOptionalParameterOperations.require_optional": "_Specs_.Azure.ClientGenerator.Core.Override.RequireOptionalParameter.requireOptional",
"specs.azure.clientgenerator.core.override.operations.RemoveOptionalParameterOperations.remove_optional": "_Specs_.Azure.ClientGenerator.Core.Override.RemoveOptionalParameter.removeOptional",
"specs.azure.clientgenerator.core.override.aio.operations.RemoveOptionalParameterOperations.remove_optional": "_Specs_.Azure.ClientGenerator.Core.Override.RemoveOptionalParameter.removeOptional"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils import recorded_by_proxy
from testpreparer import OverrideClientTestBase, OverridePreparer


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestOverrideRemoveOptionalParameterOperations(OverrideClientTestBase):
@OverridePreparer()
@recorded_by_proxy
def test_remove_optional_parameter_remove_optional(self, override_endpoint):
client = self.create_client(endpoint=override_endpoint)
response = client.remove_optional_parameter.remove_optional(
param1="str",
)

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


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestOverrideRemoveOptionalParameterOperationsAsync(OverrideClientTestBaseAsync):
@OverridePreparer()
@recorded_by_proxy_async
async def test_remove_optional_parameter_remove_optional(self, override_endpoint):
client = self.create_async_client(endpoint=override_endpoint)
response = await client.remove_optional_parameter.remove_optional(
param1="str",
)

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


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestOverrideRequireOptionalParameterOperations(OverrideClientTestBase):
@OverridePreparer()
@recorded_by_proxy
def test_require_optional_parameter_require_optional(self, override_endpoint):
client = self.create_client(endpoint=override_endpoint)
response = client.require_optional_parameter.require_optional(
param1="str",
param2="str",
)

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


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestOverrideRequireOptionalParameterOperationsAsync(OverrideClientTestBaseAsync):
@OverridePreparer()
@recorded_by_proxy_async
async def test_require_optional_parameter_require_optional(self, override_endpoint):
client = self.create_async_client(endpoint=override_endpoint)
response = await client.require_optional_parameter.require_optional(
param1="str",
param2="str",
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

from ._configuration import OverrideClientConfiguration
from ._utils.serialization import Deserializer, Serializer
from .operations import GroupParametersOperations, ReorderParametersOperations
from .operations import (
GroupParametersOperations,
RemoveOptionalParameterOperations,
ReorderParametersOperations,
RequireOptionalParameterOperations,
)


class OverrideClient: # pylint: disable=client-accepts-api-version-keyword
Expand All @@ -28,6 +33,12 @@ class OverrideClient: # pylint: disable=client-accepts-api-version-keyword
:ivar group_parameters: GroupParametersOperations operations
:vartype group_parameters:
specs.azure.clientgenerator.core.override.operations.GroupParametersOperations
:ivar require_optional_parameter: RequireOptionalParameterOperations operations
:vartype require_optional_parameter:
specs.azure.clientgenerator.core.override.operations.RequireOptionalParameterOperations
:ivar remove_optional_parameter: RemoveOptionalParameterOperations operations
:vartype remove_optional_parameter:
specs.azure.clientgenerator.core.override.operations.RemoveOptionalParameterOperations
:keyword endpoint: Service host. Default value is "http://localhost:3000".
:paramtype endpoint: str
"""
Expand Down Expand Up @@ -66,6 +77,12 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self.group_parameters = GroupParametersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.require_optional_parameter = RequireOptionalParameterOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.remove_optional_parameter = RemoveOptionalParameterOperations(
self._client, self._config, self._serialize, self._deserialize
)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

from .._utils.serialization import Deserializer, Serializer
from ._configuration import OverrideClientConfiguration
from .operations import GroupParametersOperations, ReorderParametersOperations
from .operations import (
GroupParametersOperations,
RemoveOptionalParameterOperations,
ReorderParametersOperations,
RequireOptionalParameterOperations,
)


class OverrideClient: # pylint: disable=client-accepts-api-version-keyword
Expand All @@ -28,6 +33,12 @@ class OverrideClient: # pylint: disable=client-accepts-api-version-keyword
:ivar group_parameters: GroupParametersOperations operations
:vartype group_parameters:
specs.azure.clientgenerator.core.override.aio.operations.GroupParametersOperations
:ivar require_optional_parameter: RequireOptionalParameterOperations operations
:vartype require_optional_parameter:
specs.azure.clientgenerator.core.override.aio.operations.RequireOptionalParameterOperations
:ivar remove_optional_parameter: RemoveOptionalParameterOperations operations
:vartype remove_optional_parameter:
specs.azure.clientgenerator.core.override.aio.operations.RemoveOptionalParameterOperations
:keyword endpoint: Service host. Default value is "http://localhost:3000".
:paramtype endpoint: str
"""
Expand Down Expand Up @@ -66,6 +77,12 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self.group_parameters = GroupParametersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.require_optional_parameter = RequireOptionalParameterOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.remove_optional_parameter = RemoveOptionalParameterOperations(
self._client, self._config, self._serialize, self._deserialize
)

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

from ._operations import ReorderParametersOperations # type: ignore
from ._operations import GroupParametersOperations # type: ignore
from ._operations import RequireOptionalParameterOperations # type: ignore
from ._operations import RemoveOptionalParameterOperations # type: ignore

from ._patch import __all__ as _patch_all
from ._patch import *
Expand All @@ -22,6 +24,8 @@
__all__ = [
"ReorderParametersOperations",
"GroupParametersOperations",
"RequireOptionalParameterOperations",
"RemoveOptionalParameterOperations",
]
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
from azure.core.tracing.decorator_async import distributed_trace_async

from ..._utils.serialization import Deserializer, Serializer
from ...operations._operations import build_group_parameters_group_request, build_reorder_parameters_reorder_request
from ...operations._operations import (
build_group_parameters_group_request,
build_remove_optional_parameter_remove_optional_request,
build_reorder_parameters_reorder_request,
build_require_optional_parameter_require_optional_request,
)
from .._configuration import OverrideClientConfiguration

T = TypeVar("T")
Expand Down Expand Up @@ -163,3 +168,139 @@ async def group(self, *, param1: str, param2: str, **kwargs: Any) -> None:

if cls:
return cls(pipeline_response, None, {}) # type: ignore


class RequireOptionalParameterOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.

Instead, you should access the following operations through
:class:`~specs.azure.clientgenerator.core.override.aio.OverrideClient`'s
:attr:`require_optional_parameter` attribute.
"""

def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: OverrideClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace_async
async def require_optional(self, param1: str, param2: str, **kwargs: Any) -> None:
"""require_optional.

:param param1: Required.
:type param1: str
:param param2: Required.
:type param2: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}

cls: ClsType[None] = kwargs.pop("cls", None)

_request = build_require_optional_parameter_require_optional_request(
param1=param1,
param2=param2,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = False
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

if cls:
return cls(pipeline_response, None, {}) # type: ignore


class RemoveOptionalParameterOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.

Instead, you should access the following operations through
:class:`~specs.azure.clientgenerator.core.override.aio.OverrideClient`'s
:attr:`remove_optional_parameter` attribute.
"""

def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: OverrideClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace_async
async def remove_optional(self, param1: str, *, param2: Optional[str] = None, **kwargs: Any) -> None:
"""remove_optional.

:param param1: Required.
:type param1: str
:keyword param2: Default value is None.
:paramtype param2: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}

cls: ClsType[None] = kwargs.pop("cls", None)

_request = build_remove_optional_parameter_remove_optional_request(
param1=param1,
param2=param2,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = False
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

if cls:
return cls(pipeline_response, None, {}) # type: ignore
Loading
Loading