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

### 2020-xx-xx - 5.3.5
Autorest core version: 3.0.6318

Modelerfour version: 4.15.421

**Bug Fixes**

- Can now correctly poll in the case of parameterized endpoints with relative polling urls #784

### 2020-09-24 - 5.3.4
Autorest core version: 3.0.6318

Expand Down
14 changes: 12 additions & 2 deletions autorest/codegen/templates/lro_operation_helper.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@

{% macro lro_operation_return(code_model, operation, async_mode) %}
{% set async_prefix = "Async" if async_mode else "" %}
{% set path_format_arguments = "" %}
{% set lro_options = (", lro_options={'final-state-via': '"+ operation.lro_options['final-state-via'] + "'}") if operation.lro_options else "" %}
{% set poller = "AsyncLROPoller" if async_mode else "LROPoller" %}
{% set operation_name = "begin_"+operation.python_name %}
{% if operation.parameters.path %}
{% set path_format_arguments = ", path_format_arguments=path_format_arguments" %}
path_format_arguments = {
{% for path_parameter in operation.parameters.path %}
'{{ path_parameter.rest_api_name }}': {{ operation.build_serialize_data_call(path_parameter, "url") }},
{% endfor %}
}

{% endif %}
{% if code_model.options['azure_arm'] %}
if polling is True: polling_method = {{ async_prefix }}ARMPolling(lro_delay{{ lro_options }}, **kwargs)
if polling is True: polling_method = {{ async_prefix }}ARMPolling(lro_delay{{ lro_options }}{{ path_format_arguments }}, **kwargs)
{% else %}
if polling is True: polling_method = {{ async_prefix }}LROBasePolling(lro_delay{{ lro_options }}, **kwargs)
if polling is True: polling_method = {{ async_prefix }}LROBasePolling(lro_delay{{ lro_options }}{{ path_format_arguments }}, **kwargs)
{% endif %}
elif polling is False: polling_method = {{ async_prefix }}NoPolling()
else: polling_method = polling
Expand Down
4 changes: 2 additions & 2 deletions autorest/codegen/templates/setup.py.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = code_model.options["package_name"] or code_model.class_name %}
{% set azure_mgmt_core_import = ', "azure-mgmt-core<2.0.0,>=1.2.0"' if code_model.options["azure_arm"] else "" %}
{% set azure_mgmt_core_import = ', "azure-mgmt-core<2.0.0,>=1.2.1"' if code_model.options["azure_arm"] else "" %}
# coding=utf-8
{{ code_model.options['license_header'] }}
# coding: utf-8
Expand All @@ -16,7 +16,7 @@ VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}"
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.0"{{ azure_mgmt_core_import }}]
REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2"{{ azure_mgmt_core_import }}]

setup(
name=NAME,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@autorest/autorest": "^3.0.0",
"@microsoft.azure/autorest.testserver": "^2.10.58"
"@microsoft.azure/autorest.testserver": "^2.10.60"
},
"files": [
"autorest/**/*.py",
Expand Down
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'AcceptanceTests/AzureReport': 'azure-report.json',
'AcceptanceTests/AzureParameterGrouping': 'azure-parameter-grouping.json',
'AcceptanceTests/CustomBaseUri': ['custom-baseUrl.json', 'custombaseurl'],
'AcceptanceTests/LroWithParameterizedEndpoints': 'lro-parameterized-endpoints.json',
}

# The list is mostly built on Swaggers that uses CloudError feature
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
import pytest
from lrowithparameterizedendpoints.aio import LROWithParamaterizedEndpoints

class TestLroWithParameterizedEndpoints:

@pytest.mark.asyncio
async def test_poll_with_parameterized_endpoints(self, credential):
async with LROWithParamaterizedEndpoints(credential=credential, host="host:3000") as client:
poller = await client.begin_poll_with_parameterized_endpoints(account_name='local', polling=True, polling_interval=0)
assert (await poller.result()) == 'success'
34 changes: 34 additions & 0 deletions test/azure/AcceptanceTests/test_lro_parameterized_endpoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------

from lrowithparameterizedendpoints import LROWithParamaterizedEndpoints

class TestLroWithParameterizedEndpoints:

def test_poll_with_parameterized_endpoints(self, credential):
client = LROWithParamaterizedEndpoints(credential=credential, host="host:3000")
poller = client.begin_poll_with_parameterized_endpoints(account_name='local', polling=True, polling_interval=0)
assert poller.result() == 'success'
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 ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints
from ._version import VERSION

__version__ = VERSION
__all__ = ['LROWithParamaterizedEndpoints']

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,58 @@
# 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 LROWithParamaterizedEndpointsConfiguration(Configuration):
"""Configuration for LROWithParamaterizedEndpoints.

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

:param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test.
:type host: str
"""

def __init__(
self,
host="host", # type: str
**kwargs # type: Any
):
# type: (...) -> None
if host is None:
raise ValueError("Parameter 'host' must not be None.")
super(LROWithParamaterizedEndpointsConfiguration, self).__init__(**kwargs)

self.host = host
kwargs.setdefault('sdk_moniker', 'lrowithparamaterizedendpoints/{}'.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,58 @@
# 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

from ._configuration import LROWithParamaterizedEndpointsConfiguration
from .operations import LROWithParamaterizedEndpointsOperationsMixin
from . import models


class LROWithParamaterizedEndpoints(LROWithParamaterizedEndpointsOperationsMixin):
"""Test Infrastructure for AutoRest.

:param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test.
:type host: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

def __init__(
self,
host="host", # type: str
**kwargs # type: Any
):
# type: (...) -> None
base_url = 'http://{accountName}{host}'
self._config = LROWithParamaterizedEndpointsConfiguration(host, **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._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)


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

def __enter__(self):
# type: () -> LROWithParamaterizedEndpoints
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,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 ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints
__all__ = ['LROWithParamaterizedEndpoints']
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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 LROWithParamaterizedEndpointsConfiguration(Configuration):
"""Configuration for LROWithParamaterizedEndpoints.

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

:param host: A string value that is used as a global part of the parameterized host. Pass in 'host:3000' to pass test.
:type host: str
"""

def __init__(
self,
host: str = "host",
**kwargs: Any
) -> None:
if host is None:
raise ValueError("Parameter 'host' must not be None.")
super(LROWithParamaterizedEndpointsConfiguration, self).__init__(**kwargs)

self.host = host
kwargs.setdefault('sdk_moniker', 'lrowithparamaterizedendpoints/{}'.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')
Loading