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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Fix dependencies of pyproject.toml for ARM SDK
4 changes: 2 additions & 2 deletions 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/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTI5NDY5NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.16.0.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTMwMTc4Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.16.0.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,65 @@ output-folder: $(python-sdks-folder)/test/azure-mgmt-pyproject/azure/mgmt/pyproj
modelerfour:
flatten-models: false
```

``` yaml $(python)
directive:
- from: swagger-document
where: $.paths
transform: >
$["/self-define/post1"] = {
"post": {
"operationId": "Operations_List",
"summary": "Process list of strings",
"description": "Processes a list of strings with no return value",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"description": "List of strings to process"
}
],
"responses": {
"204": {
"description": "Operation completed successfully with no content"
}
}
}
};
- from: swagger-document
where: $.paths
transform: >
$["/self-define/post2"] = {
"post": {
"operationId": "SelfDefine_Post",
"summary": "Process list of strings",
"description": "Processes a list of strings with no return value",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"description": "List of strings to process"
}
],
"responses": {
"204": {
"description": "Operation completed successfully with no content"
}
}
}
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"azure.mgmt.pyproject.operations.HttpSuccessOperations.head204": null,
"azure.mgmt.pyproject.aio.operations.HttpSuccessOperations.head204": null,
"azure.mgmt.pyproject.operations.HttpSuccessOperations.head404": null,
"azure.mgmt.pyproject.aio.operations.HttpSuccessOperations.head404": null
"azure.mgmt.pyproject.aio.operations.HttpSuccessOperations.head404": null,
"azure.mgmt.pyproject.operations.Operations.list": null,
"azure.mgmt.pyproject.aio.operations.Operations.list": null,
"azure.mgmt.pyproject.operations.SelfDefineOperations.post": null,
"azure.mgmt.pyproject.aio.operations.SelfDefineOperations.post": null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ._configuration import PyprojectMgmtClientConfiguration
from ._utils.serialization import Deserializer, Serializer
from .operations import HttpSuccessOperations
from .operations import HttpSuccessOperations, Operations, SelfDefineOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
Expand All @@ -31,6 +31,10 @@ class PyprojectMgmtClient: # pylint: disable=client-accepts-api-version-keyword

:ivar http_success: HttpSuccessOperations operations
:vartype http_success: azure.mgmt.pyproject.operations.HttpSuccessOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.pyproject.operations.Operations
:ivar self_define: SelfDefineOperations operations
:vartype self_define: azure.mgmt.pyproject.operations.SelfDefineOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is None.
Expand Down Expand Up @@ -82,6 +86,8 @@ def __init__(
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.self_define = SelfDefineOperations(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 @@ -19,7 +19,7 @@

from .._utils.serialization import Deserializer, Serializer
from ._configuration import PyprojectMgmtClientConfiguration
from .operations import HttpSuccessOperations
from .operations import HttpSuccessOperations, Operations, SelfDefineOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
Expand All @@ -31,6 +31,10 @@ class PyprojectMgmtClient: # pylint: disable=client-accepts-api-version-keyword

:ivar http_success: HttpSuccessOperations operations
:vartype http_success: azure.mgmt.pyproject.aio.operations.HttpSuccessOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.pyproject.aio.operations.Operations
:ivar self_define: SelfDefineOperations operations
:vartype self_define: azure.mgmt.pyproject.aio.operations.SelfDefineOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param base_url: Service URL. Default value is None.
Expand Down Expand Up @@ -84,6 +88,8 @@ def __init__(
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.self_define = SelfDefineOperations(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 @@ -13,13 +13,17 @@
from ._patch import * # pylint: disable=unused-wildcard-import

from ._http_success_operations import HttpSuccessOperations # type: ignore
from ._operations import Operations # type: ignore
from ._self_define_operations import SelfDefineOperations # type: ignore

from ._patch import __all__ as _patch_all
from ._patch import *
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"HttpSuccessOperations",
"Operations",
"SelfDefineOperations",
]
__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 @@ -28,6 +28,7 @@

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
List = list


class HttpSuccessOperations:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# 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) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, Callable, IO, Optional, TypeVar, Union, overload

from azure.core import AsyncPipelineClient
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat

from ..._utils.serialization import Deserializer, Serializer
from ...operations._operations import build_list_request
from .._configuration import PyprojectMgmtClientConfiguration

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
List = list


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

Instead, you should access the following operations through
:class:`~azure.mgmt.pyproject.aio.PyprojectMgmtClient`'s
:attr:`operations` 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: PyprojectMgmtClientConfiguration = 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")

@overload
async def list(self, body: List[str], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""Process list of strings.

Processes a list of strings with no return value.

:param body: List of strings to process. Required.
:type body: list[str]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def list(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""Process list of strings.

Processes a list of strings with no return value.

:param body: List of strings to process. Required.
:type body: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace_async
async def list(self, body: Union[List[str], IO[bytes]], **kwargs: Any) -> None:
"""Process list of strings.

Processes a list of strings with no return value.

:param body: List of strings to process. Is either a [str] type or a IO[bytes] type. Required.
:type body: list[str] or IO[bytes]
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

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

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IOBase, bytes)):
_content = body
else:
_json = self._serialize.body(body, "[str]")

_request = build_list_request(
content_type=content_type,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
_request.url = self._client.format_url(_request.url)

_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, error_format=ARMErrorFormat)

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