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
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Change Log

### 2020-xx-xx - 5.1.0-preview.8
### 2020-xx-xx - 5.2.0-preview.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping minor version since it's a breaking change and the diff is big

Autorest Core version: 3.0.6302
Modelerfour version: 4.15.400

**Breaking Changes**

- Removed the `_async` suffix from async files #759

**New Features**

- Updated minimum `azure-core` version to 1.8.0 #747
Expand Down
8 changes: 4 additions & 4 deletions autorest/codegen/models/operation_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ def imports(self, async_mode: bool, has_schemas: bool) -> FileImport:
file_import.add_from_import("..", "models", ImportType.LOCAL)
return file_import

def get_filename(self, async_mode: bool) -> str:
@property
def filename(self) -> str:
basename = self.name
if self.is_empty_operation_group:
basename = self.code_model.module_name
async_suffix = "_async" if async_mode else ""

if basename == "operations":
return f"_operations{async_suffix}"
return f"_{basename}_operations{async_suffix}"
return f"_operations"
return f"_{basename}_operations"

@property
def is_empty_operation_group(self) -> bool:
Expand Down
12 changes: 6 additions & 6 deletions autorest/codegen/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _serialize_and_write_operations_folder(
if not code_model.options["no_async"]:
operations_async_init_serializer = OperationsInitSerializer(code_model=code_model, env=env, async_mode=True)
self._autorestapi.write_file(
namespace_path / Path("aio") / Path(f"operations_async") / Path("__init__.py"),
namespace_path / Path("aio") / Path(f"operations") / Path("__init__.py"),
operations_async_init_serializer.serialize(),
)

Expand All @@ -108,7 +108,7 @@ def _serialize_and_write_operations_folder(
code_model=code_model, env=env, operation_group=operation_group, async_mode=False
)
self._autorestapi.write_file(
namespace_path / Path(f"operations") / Path(f"{operation_group.get_filename(async_mode=False)}.py"),
namespace_path / Path(f"operations") / Path(f"{operation_group.filename}.py"),
operation_group_serializer.serialize(),
)

Expand All @@ -121,8 +121,8 @@ def _serialize_and_write_operations_folder(
(
namespace_path
/ Path("aio")
/ Path(f"operations_async")
/ Path(f"{operation_group.get_filename(async_mode=True)}.py")
/ Path(f"operations")
/ Path(f"{operation_group.filename}.py")
),
operation_group_async_serializer.serialize(),
)
Expand Down Expand Up @@ -193,13 +193,13 @@ def _serialize_and_write_aio_folder(self, code_model: CodeModel, env: Environmen

# Write the service client
self._autorestapi.write_file(
aio_path / Path(f"_{code_model.module_name}_async.py"),
aio_path / Path(f"_{code_model.module_name}.py"),
aio_general_serializer.serialize_service_client_file(),
)

# Write the config file
self._autorestapi.write_file(
aio_path / Path("_configuration_async.py"), aio_general_serializer.serialize_config_file()
aio_path / Path("_configuration.py"), aio_general_serializer.serialize_config_file()
)

def _serialize_and_write_metadata(self, code_model: CodeModel, env: Environment, namespace_path: Path) -> None:
Expand Down
3 changes: 1 addition & 2 deletions autorest/codegen/templates/init.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% set async_suffix = "_async" if async_mode else "" %}
# coding=utf-8
{{ code_model.options['license_header'] }}

from ._{{ code_model.module_name + async_suffix }} import {{ code_model.class_name }}
from ._{{ code_model.module_name }} import {{ code_model.class_name }}
{% if not async_mode and code_model.options['package_version']%}
from ._version import VERSION

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% set async_suffix = "_async" if async_mode else "" %}
{# actual template starts here #}
# coding=utf-8
{{ code_model.options['license_header'] }}

{% for operation_group in operation_groups %}
from .{{ operation_group.get_filename(async_mode) }} import {{ operation_group.class_name }}
from .{{ operation_group.filename }} import {{ operation_group.class_name }}
{% endfor %}

__all__ = [
Expand Down
8 changes: 3 additions & 5 deletions autorest/codegen/templates/service_client.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{% import 'keywords.jinja2' as keywords with context %}
{% set config_import = "._configuration_async" if async_mode else "._configuration" %}
{% set operations_import = ".operations_async" if async_mode else ".operations" %}
{% set path_to_models = ".." if async_mode else "." %}
{% macro method_signature() %}
def __init__(
Expand Down Expand Up @@ -33,9 +31,9 @@ def __init__(

{{ imports }}

from {{ config_import }} import {{ code_model.class_name }}Configuration
from ._configuration import {{ code_model.class_name }}Configuration
{% for operation_group in code_model.operation_groups %}
from {{ operations_import }} import {{ operation_group.class_name }}
from .operations import {{ operation_group.class_name }}
{% endfor %}
{% if code_model.sorted_schemas %}
from {{ path_to_models }} import models
Expand All @@ -48,7 +46,7 @@ class {{ code_model.class_name }}({{ base_class }}):
{% for operation_group in code_model.operation_groups|rejectattr("is_empty_operation_group") %}
:ivar {{ operation_group.name }}: {{ operation_group.class_name }} operations
{% if async_mode %}
:vartype {{ operation_group.name }}: {{ code_model.namespace }}.aio.operations_async.{{ operation_group.class_name }}
:vartype {{ operation_group.name }}: {{ code_model.namespace }}.aio.operations.{{ operation_group.class_name }}
{% else %}
:vartype {{ operation_group.name }}: {{ code_model.namespace }}.operations.{{ operation_group.class_name }}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions autorest/multiapi/serializers/multiapi_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
self.conf = conf
self.async_mode = async_mode
self._autorestapi = autorestapi
self.service_client_filename = service_client_filename + "_async" if async_mode else service_client_filename
self.service_client_filename = service_client_filename
self.env = Environment(
loader=PackageLoader("autorest.multiapi", "templates"),
keep_trailing_newline=True,
Expand All @@ -41,13 +41,13 @@ def serialize(self):
self.serialize_multiapi_client()
)

configuration_filename = "_configuration_async.py" if self.async_mode else "_configuration.py"
configuration_filename = "_configuration.py"
self._autorestapi.write_file(
self._get_file_path(configuration_filename),
self.serialize_multiapi_config()
)

operation_mixins_filename = "_operations_mixin_async.py" if self.async_mode else "_operations_mixin.py"
operation_mixins_filename = "_operations_mixin.py"
if self.conf["mixin_operations"]:
self._autorestapi.write_file(
self._get_file_path(operation_mixins_filename),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class {{ client_name }}OperationsMixin(object):
{% for api in metadata['available_apis']|sort %}
{% set if_statement = "if" if loop.first else "elif" %}
{{ if_statement }} api_version == '{{ mod_to_api_version[api] }}':
from {{ ".." if async_mode else "." }}{{ api }}{{ ".aio" if async_mode else "" }}.operations{{ "_async" if async_mode else "" }} import {{ client_name }}OperationsMixin as OperationClass
from {{ ".." if async_mode else "." }}{{ api }}{{ ".aio" if async_mode else "" }}.operations import {{ client_name }}OperationsMixin as OperationClass
{% endfor %}
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
Expand Down
10 changes: 4 additions & 6 deletions autorest/multiapi/templates/multiapi_service_client.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def __init__(
**kwargs # type: Any
){{" -> None" if async_mode else "" }}:{% endmacro %}
{# actual template starts here #}
{% set config_import = "._configuration_async" if async_mode else "._configuration" %}
{% set operations_mixin_import = "._operations_mixin_async" if async_mode else "._operations_mixin" %}
{% set pipeline_client = "ARMPipelineClient" if azure_arm else "PipelineClient" %}
{% set relative_path = ".." if async_mode else "." %}
{% set def = "async def" if async_mode else "def" %}
Expand All @@ -44,8 +42,8 @@ from msrest import Serializer, Deserializer

from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from {{ config_import }} import {{ client_name }}Configuration
{% if mixin_operations %}from {{ operations_mixin_import }} import {{ client_name }}OperationsMixin{% endif %}
from ._configuration import {{ client_name }}Configuration
{% if mixin_operations %}from ._operations_mixin import {{ client_name }}OperationsMixin{% endif %}

class _SDKClient(object):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -142,14 +140,14 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
"""Instance depends on the API version:

{% for api in available_apis | sort %}
* {{ mod_to_api_version[api[0]] }}: :class:`{{ api[1] }}<{{ module_name }}.{{ api[0] }}{{ ".aio" if async_mode else "" }}.operations{{ "_async" if async_mode else "" }}.{{ api[1] }}>`
* {{ mod_to_api_version[api[0]] }}: :class:`{{ api[1] }}<{{ module_name }}.{{ api[0] }}{{ ".aio" if async_mode else "" }}.operations.{{ api[1] }}>`
{% endfor %}
"""
api_version = self._get_api_version('{{ operation_group }}')
{% for api in available_apis | sort %}
{% set if_statement = "if" if loop.first else "elif" %}
{{ if_statement }} api_version == '{{ mod_to_api_version[api[0]] }}':
from {{ relative_path }}{{ api[0] }}.{{ "aio." if async_mode else "" }}operations{{ "_async" if async_mode else "" }} import {{ api[1] }} as OperationClass
from {{ relative_path }}{{ api[0] }}.{{ "aio." if async_mode else "" }}operations import {{ api[1] }} as OperationClass
{% endfor %}
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/python",
"version": "5.1.0-preview.7",
"version": "5.2.0-preview.1",
"description": "The Python extension for generators in AutoRest.",
"scripts": {
"prepare": "node run-python3.js prepare.py",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._auto_rest_duration_test_service_async import AutoRestDurationTestService
from ._auto_rest_duration_test_service import AutoRestDurationTestService
__all__ = ['AutoRestDurationTestService']
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

from ._configuration_async import AutoRestDurationTestServiceConfiguration
from .operations_async import DurationOperations
from ._configuration import AutoRestDurationTestServiceConfiguration
from .operations import DurationOperations
from .. import models


class AutoRestDurationTestService(object):
"""Test Infrastructure for AutoRest.

:ivar duration: DurationOperations operations
:vartype duration: bodyduration.aio.operations_async.DurationOperations
:vartype duration: bodyduration.aio.operations.DurationOperations
:param str base_url: Service URL
"""

Expand Down
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 ._duration_operations_async import DurationOperations
from ._duration_operations import DurationOperations

__all__ = [
'DurationOperations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._auto_rest_parameter_grouping_test_service_async import AutoRestParameterGroupingTestService
from ._auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService
__all__ = ['AutoRestParameterGroupingTestService']
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

from ._configuration_async import AutoRestParameterGroupingTestServiceConfiguration
from .operations_async import ParameterGroupingOperations
from ._configuration import AutoRestParameterGroupingTestServiceConfiguration
from .operations import ParameterGroupingOperations
from .. import models


class AutoRestParameterGroupingTestService(object):
"""Test Infrastructure for AutoRest.

:ivar parameter_grouping: ParameterGroupingOperations operations
:vartype parameter_grouping: azureparametergrouping.aio.operations_async.ParameterGroupingOperations
:vartype parameter_grouping: azureparametergrouping.aio.operations.ParameterGroupingOperations
:param str base_url: Service URL
"""

Expand Down
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 ._parameter_grouping_operations_async import ParameterGroupingOperations
from ._parameter_grouping_operations import ParameterGroupingOperations

__all__ = [
'ParameterGroupingOperations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._auto_rest_report_service_for_azure_async import AutoRestReportServiceForAzure
from ._auto_rest_report_service_for_azure import AutoRestReportServiceForAzure
__all__ = ['AutoRestReportServiceForAzure']
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

from ._configuration_async import AutoRestReportServiceForAzureConfiguration
from .operations_async import AutoRestReportServiceForAzureOperationsMixin
from ._configuration import AutoRestReportServiceForAzureConfiguration
from .operations import AutoRestReportServiceForAzureOperationsMixin
from .. import models


Expand Down
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_report_service_for_azure_operations_async import AutoRestReportServiceForAzureOperationsMixin
from ._auto_rest_report_service_for_azure_operations import AutoRestReportServiceForAzureOperationsMixin

__all__ = [
'AutoRestReportServiceForAzureOperationsMixin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._auto_rest_azure_special_parameters_test_client_async import AutoRestAzureSpecialParametersTestClient
from ._auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient
__all__ = ['AutoRestAzureSpecialParametersTestClient']
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential

from ._configuration_async import AutoRestAzureSpecialParametersTestClientConfiguration
from .operations_async import XMsClientRequestIdOperations
from .operations_async import SubscriptionInCredentialsOperations
from .operations_async import SubscriptionInMethodOperations
from .operations_async import ApiVersionDefaultOperations
from .operations_async import ApiVersionLocalOperations
from .operations_async import SkipUrlEncodingOperations
from .operations_async import OdataOperations
from .operations_async import HeaderOperations
from ._configuration import AutoRestAzureSpecialParametersTestClientConfiguration
from .operations import XMsClientRequestIdOperations
from .operations import SubscriptionInCredentialsOperations
from .operations import SubscriptionInMethodOperations
from .operations import ApiVersionDefaultOperations
from .operations import ApiVersionLocalOperations
from .operations import SkipUrlEncodingOperations
from .operations import OdataOperations
from .operations import HeaderOperations
from .. import models


class AutoRestAzureSpecialParametersTestClient(object):
"""Test Infrastructure for AutoRest.

:ivar xms_client_request_id: XMsClientRequestIdOperations operations
:vartype xms_client_request_id: azurespecialproperties.aio.operations_async.XMsClientRequestIdOperations
:vartype xms_client_request_id: azurespecialproperties.aio.operations.XMsClientRequestIdOperations
:ivar subscription_in_credentials: SubscriptionInCredentialsOperations operations
:vartype subscription_in_credentials: azurespecialproperties.aio.operations_async.SubscriptionInCredentialsOperations
:vartype subscription_in_credentials: azurespecialproperties.aio.operations.SubscriptionInCredentialsOperations
:ivar subscription_in_method: SubscriptionInMethodOperations operations
:vartype subscription_in_method: azurespecialproperties.aio.operations_async.SubscriptionInMethodOperations
:vartype subscription_in_method: azurespecialproperties.aio.operations.SubscriptionInMethodOperations
:ivar api_version_default: ApiVersionDefaultOperations operations
:vartype api_version_default: azurespecialproperties.aio.operations_async.ApiVersionDefaultOperations
:vartype api_version_default: azurespecialproperties.aio.operations.ApiVersionDefaultOperations
:ivar api_version_local: ApiVersionLocalOperations operations
:vartype api_version_local: azurespecialproperties.aio.operations_async.ApiVersionLocalOperations
:vartype api_version_local: azurespecialproperties.aio.operations.ApiVersionLocalOperations
:ivar skip_url_encoding: SkipUrlEncodingOperations operations
:vartype skip_url_encoding: azurespecialproperties.aio.operations_async.SkipUrlEncodingOperations
:vartype skip_url_encoding: azurespecialproperties.aio.operations.SkipUrlEncodingOperations
:ivar odata: OdataOperations operations
:vartype odata: azurespecialproperties.aio.operations_async.OdataOperations
:vartype odata: azurespecialproperties.aio.operations.OdataOperations
:ivar header: HeaderOperations operations
:vartype header: azurespecialproperties.aio.operations_async.HeaderOperations
:vartype header: azurespecialproperties.aio.operations.HeaderOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The subscription id, which appears in the path, always modeled in credentials. The value is always '1234-5678-9012-3456'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._xms_client_request_id_operations_async import XMsClientRequestIdOperations
from ._subscription_in_credentials_operations_async import SubscriptionInCredentialsOperations
from ._subscription_in_method_operations_async import SubscriptionInMethodOperations
from ._api_version_default_operations_async import ApiVersionDefaultOperations
from ._api_version_local_operations_async import ApiVersionLocalOperations
from ._skip_url_encoding_operations_async import SkipUrlEncodingOperations
from ._odata_operations_async import OdataOperations
from ._header_operations_async import HeaderOperations
from ._xms_client_request_id_operations import XMsClientRequestIdOperations
from ._subscription_in_credentials_operations import SubscriptionInCredentialsOperations
from ._subscription_in_method_operations import SubscriptionInMethodOperations
from ._api_version_default_operations import ApiVersionDefaultOperations
from ._api_version_local_operations import ApiVersionLocalOperations
from ._skip_url_encoding_operations import SkipUrlEncodingOperations
from ._odata_operations import OdataOperations
from ._header_operations import HeaderOperations

__all__ = [
'XMsClientRequestIdOperations',
Expand Down
Loading