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
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Modelerfour version: 4.13.351
**Bug Fixes**
- Corrected generation of the item name of paging response when extracting data #648
- Corrected return type typing annotation for operations that return an optional body #656
- Fixed mypy issue by only setting the generated `deserialized` variable to None if the operation has an optional return typ #656
- Fixed mypy issue by only setting the generated `deserialized` variable to None if the operation has an optional return type #656
- Fixed generation of pkgutil init files #661

### 2020-05-22 - 5.0.0-preview.8
Modelerfour version: 4.13.351
Expand Down
4 changes: 2 additions & 2 deletions autorest/codegen/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def _serialize_and_write_top_level_folder(

self._autorestapi.write_file(namespace_path / Path("__init__.py"), general_serializer.serialize_init_file())
p = namespace_path.parent
while p.parent != Path("."):
while p != Path("."):
# write pkgutil init file
self._autorestapi.write_file(
namespace_path / Path("__init__.py"), general_serializer.serialize_pkgutil_init_file()
p / Path("__init__.py"), general_serializer.serialize_pkgutil_init_file()
)
p = p.parent

Expand Down
17 changes: 17 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,30 @@ def regenerate_python_arm(c, swagger_name=None, debug=False):
}
regen_expected(c, opts, debug)

@task
def regenerate_namespace_folders_test(c, debug=False):
# regenerate a swagger (randomly chose BodyArray) to have a namespace length > 1
# to test pkgutil logic
default_mapping = {'AcceptanceTests/BodyArrayWithNamespaceFolders': ['body-array.json', 'vanilla.body.array']}
opts = {
'output_base_dir': 'test/vanilla',
'input_base_dir': swagger_dir,
'mappings': default_mapping,
'output_dir': 'Expected',
'flattening_threshold': '1',
'vanilla': True,
'keep_version': True,
'ns_prefix': True
}
regen_expected(c, opts, debug)

@task
def regenerate(c, swagger_name=None, debug=False):
# regenerate expected code for tests
regenerate_python(c, swagger_name, debug)
regenerate_python_azure(c, swagger_name, debug)
regenerate_python_arm(c, swagger_name, debug)
regenerate_namespace_folders_test(c, debug)
if not swagger_name:
regenerate_multiapi(c, debug)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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.
# --------------------------------------------------------------------------
# coding: utf-8

from setuptools import setup, find_packages

NAME = "autorestswaggerbatarrayservice"
VERSION = "0.1.0"

# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]

setup(
name=NAME,
version=VERSION,
description="AutoRestSwaggerBATArrayService",
author_email="",
url="",
keywords=["Swagger", "AutoRestSwaggerBATArrayService"],
install_requires=REQUIRES,
packages=find_packages(),
include_package_data=True,
long_description="""\
Test Infrastructure for AutoRest Swagger BAT.
"""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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 ._auto_rest_swagger_bat_array_service import AutoRestSwaggerBATArrayService
from ._version import VERSION

__version__ = VERSION
__all__ = ['AutoRestSwaggerBATArrayService']

try:
from ._patch import patch_sdk
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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 typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from ._configuration import AutoRestSwaggerBATArrayServiceConfiguration
from .operations import ArrayOperations
from . import models


class AutoRestSwaggerBATArrayService(object):
"""Test Infrastructure for AutoRest Swagger BAT.

:ivar array: ArrayOperations operations
:vartype array: vanilla.body.array.operations.ArrayOperations
:param str base_url: Service URL
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

def __init__(
self,
base_url=None, # type: Optional[str]
**kwargs # type: Any
):
# type: (...) -> None
if not base_url:
base_url = 'http://localhost:3000'
self._config = AutoRestSwaggerBATArrayServiceConfiguration(**kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.array = ArrayOperations(
self._client, self._config, self._serialize, self._deserialize)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> AutoRestSwaggerBATArrayService
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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 typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any


class AutoRestSwaggerBATArrayServiceConfiguration(Configuration):
"""Configuration for AutoRestSwaggerBATArrayService.

Note that all parameters used to create this instance are saved as instance
attributes.
"""

def __init__(
self,
**kwargs # type: Any
):
# type: (...) -> None
super(AutoRestSwaggerBATArrayServiceConfiguration, self).__init__(**kwargs)

kwargs.setdefault('sdk_moniker', 'autorestswaggerbatarrayservice/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
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.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')
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.
# --------------------------------------------------------------------------

VERSION = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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 ._auto_rest_swagger_bat_array_service_async import AutoRestSwaggerBATArrayService
__all__ = ['AutoRestSwaggerBATArrayService']
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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 typing import Any, Optional

from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

from ._configuration_async import AutoRestSwaggerBATArrayServiceConfiguration
from .operations_async import ArrayOperations
from .. import models


class AutoRestSwaggerBATArrayService(object):
"""Test Infrastructure for AutoRest Swagger BAT.

:ivar array: ArrayOperations operations
:vartype array: vanilla.body.array.aio.operations_async.ArrayOperations
:param str base_url: Service URL
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

def __init__(
self,
base_url: Optional[str] = None,
**kwargs: Any
) -> None:
if not base_url:
base_url = 'http://localhost:3000'
self._config = AutoRestSwaggerBATArrayServiceConfiguration(**kwargs)
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.array = ArrayOperations(
self._client, self._config, self._serialize, self._deserialize)

async def close(self) -> None:
await self._client.close()

async def __aenter__(self) -> "AutoRestSwaggerBATArrayService":
await self._client.__aenter__()
return self

async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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 typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .._version import VERSION


class AutoRestSwaggerBATArrayServiceConfiguration(Configuration):
"""Configuration for AutoRestSwaggerBATArrayService.

Note that all parameters used to create this instance are saved as instance
attributes.
"""

def __init__(
self,
**kwargs: Any
) -> None:
super(AutoRestSwaggerBATArrayServiceConfiguration, self).__init__(**kwargs)

kwargs.setdefault('sdk_moniker', 'autorestswaggerbatarrayservice/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs: Any
) -> 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.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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 ._array_operations_async import ArrayOperations

__all__ = [
'ArrayOperations',
]
Loading