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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Modelerfour version: 4.15.378
- Correctly have default behavior of csv for array query parameters when collection format is not specified in the swagger
(taken from m4 update - perks PR #118)
- Fix bug when generating parameters with client default value and constant schema #707
- Fix name in setup.py to default to `package-name` if set #721

### 2020-07-07 - 5.1.0-preview.4
Modelerfour version: 4.15.378
Expand Down
5 changes: 3 additions & 2 deletions autorest/codegen/templates/setup.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% set name = code_model.options["package_name"] or code_model.class_name %}
# coding=utf-8
{{ code_model.options['license_header'] }}
# coding: utf-8

from setuptools import setup, find_packages

NAME = "{{ code_model.class_name|lower }}"
NAME = "{{ name|lower }}"
VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}"

# To install the library, run the following
Expand All @@ -19,7 +20,7 @@ REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"]
setup(
name=NAME,
version=VERSION,
description="{{ code_model.class_name }}",
description="{{ name }}",
author_email="",
url="",
keywords=["Swagger", "{{ code_model.class_name }}"],
Expand Down
23 changes: 23 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def regen_expected(c, opts, debug):
args.append(f"--override-info.description={opts['override-info.description']}")
if opts.get('credential-default-policy-type'):
args.append(f"--credential-default-policy-type={opts['credential-default-policy-type']}")
if opts.get('package-name'):
args.append(f"--package-name={opts['package-name']}")
if opts.get('override-client-name'):
args.append(f"--override-client-name={opts['override-client-name']}")

cmd_line = '{} {}'.format(_AUTOREST_CMD_LINE, " ".join(args))
print(Fore.YELLOW + f'Queuing up: {cmd_line}')
Expand Down Expand Up @@ -262,6 +266,24 @@ def regenerate_credential_default_policy(c, debug=False):
}
regen_expected(c, opts, debug)

@task
def regenerate_package_name_setup_py(c, debug=False):
default_mapping = {'AcceptanceTests/BodyByteWithPackageName': 'body-byte.json'}
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,
'package-name': 'package-name',
'override-client-name': 'class_name'
}
regen_expected(c, opts, debug)


@task
def regenerate(c, swagger_name=None, debug=False):
# regenerate expected code for tests
Expand All @@ -272,6 +294,7 @@ def regenerate(c, swagger_name=None, debug=False):
regenerate_namespace_folders_test(c, debug)
regenerate_multiapi(c, debug)
regenerate_credential_default_policy(c, debug)
regenerate_package_name_setup_py(c, debug)


@task
Expand Down
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 ._class_name import ClassName
from ._version import VERSION

__version__ = VERSION
__all__ = ['ClassName']

try:
from ._patch import patch_sdk # type: ignore
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 ClassNameConfiguration
from .operations import ByteOperations
from . import models


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

:ivar byte: ByteOperations operations
:vartype byte: bodybytewithpackagename.operations.ByteOperations
: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 = ClassNameConfiguration(**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.byte = ByteOperations(
self._client, self._config, self._serialize, self._deserialize)

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

def __enter__(self):
# type: () -> ClassName
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,51 @@
# 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 ClassNameConfiguration(Configuration):
"""Configuration for ClassName.

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

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

kwargs.setdefault('sdk_moniker', 'package-name/{}'.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.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')
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 ._class_name_async import ClassName
__all__ = ['ClassName']
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 ClassNameConfiguration
from .operations_async import ByteOperations
from .. import models


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

:ivar byte: ByteOperations operations
:vartype byte: bodybytewithpackagename.aio.operations_async.ByteOperations
: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 = ClassNameConfiguration(**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.byte = ByteOperations(
self._client, self._config, self._serialize, self._deserialize)

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

async def __aenter__(self) -> "ClassName":
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,45 @@
# 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 ClassNameConfiguration(Configuration):
"""Configuration for ClassName.

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

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

kwargs.setdefault('sdk_moniker', 'package-name/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**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 ._byte_operations_async import ByteOperations

__all__ = [
'ByteOperations',
]
Loading