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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

**Breaking Changes**

- Default to generating DPG SDKs with `--version-tolerant` now defaulting to `true`. For a list of flag default changes, please
see [here](https://github.com/Azure/autorest.python/issues/1186) #1304
- Only generate Python3 SDKs #1297
- Don't reformat initial query parameters into the next link #1297
- Don't generate operations with more than two body types. SDK authors need to implement this operation themselves #1300

**Breaking Changes in Version Tolerant**
**New Features**

- Don't generate operations with more than two body types. SDK authors need to implement this operation themselves #1300
- Automatically format generated code with `black`. To not format, pass in `--black=false` #1304

### 2022-06-13 - 5.19.0

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio

#### Python code gen

```yaml !$(multiapiscript)
# default values for version tolerant and black
black: true
```

```yaml !$(low-level-client)
version-tolerant: true
```

```yaml !$(low-level-client) && !$(version-tolerant)
modelerfour:
group-parameters: true
Expand Down
2 changes: 1 addition & 1 deletion autorest/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _build_code_model_options(self) -> Dict[str, Any]:
bool, self._autorestapi.get_boolean_value("low-level-client", False)
)
version_tolerant = cast(
bool, self._autorestapi.get_boolean_value("version-tolerant", False)
bool, self._autorestapi.get_boolean_value("version-tolerant")
)
show_operations = self._autorestapi.get_boolean_value(
"show-operations", not low_level_client
Expand Down
4 changes: 1 addition & 3 deletions autorest/m4reformatter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,7 @@ def update_credential(
"skipUrlEncoding": True,
"inOverload": False,
}
if self._autorestapi.get_boolean_value(
"version-tolerant"
) or self._autorestapi.get_boolean_value("low-level-client"):
if self.version_tolerant or self.low_level_client:
parameters.append(credential)
else:
parameters.insert(0, credential)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._auto_rest_head_test_service import AutoRestHeadTestService
from ._client import AutoRestHeadTestService
from ._version import VERSION

__version__ = VERSION
Expand All @@ -17,7 +17,8 @@
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk
__all__ = ['AutoRestHeadTestService']

__all__ = ["AutoRestHeadTestService"]
__all__.extend([p for p in _patch_all if p not in __all__])

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,36 @@
# pylint: disable=unused-import,ungrouped-imports
from typing import Dict


class AutoRestHeadTestService: # pylint: disable=client-accepts-api-version-keyword
"""Test Infrastructure for AutoRest.

:ivar http_success: HttpSuccessOperations operations
:vartype http_success: azure.key.credential.sample.operations.HttpSuccessOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
:keyword endpoint: Service URL. Default value is "http://localhost:3000".
:paramtype endpoint: str
"""

def __init__(
self,
credential: AzureKeyCredential,
base_url: str = "http://localhost:3000",
**kwargs: Any
self, credential: AzureKeyCredential, *, endpoint: str = "http://localhost:3000", **kwargs: Any
) -> None:
self._config = AutoRestHeadTestServiceConfiguration(credential=credential, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
self._client = PipelineClient(base_url=endpoint, config=self._config, **kwargs)

client_models = {} # type: Dict[str, Any]
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
self.http_success = HttpSuccessOperations(
self._client, self._config, self._serialize, self._deserialize
)

self.http_success = HttpSuccessOperations(self._client, self._config, self._serialize, self._deserialize)

def _send_request(
self,
request: HttpRequest,
**kwargs: Any
) -> HttpResponse:
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,29 @@ class AutoRestHeadTestServiceConfiguration(Configuration): # pylint: disable=to
:type credential: ~azure.core.credentials.AzureKeyCredential
"""

def __init__(
self,
credential: AzureKeyCredential,
**kwargs: Any
) -> None:
def __init__(self, credential: AzureKeyCredential, **kwargs: Any) -> None:
super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
kwargs.setdefault('sdk_moniker', 'key-credential-sample/{}'.format(VERSION))
kwargs.setdefault("sdk_moniker", "key-credential-sample/{}".format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
self, **kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.AzureKeyCredentialPolicy(self.credential, "Ocp-Apim-Subscription-Key", **kwargs)
self.authentication_policy = policies.AzureKeyCredentialPolicy(
self.credential, "Ocp-Apim-Subscription-Key", **kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

__all__ = [] # type: List[str] # Add all objects you want publicly available to users at this package level


def patch_sdk():
"""Do not remove from this file.

Expand Down
Loading