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
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Autorest Core version: 3.0.6306

Modelerfour version: 4.15.416

**Breaking Changes**

- Raise `ValueError` instead of `NotImplementedError` if API version code doesn't exist #764

### 2020-08-31 - 5.2.0-preview.1
Autorest Core version: 3.0.6306

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class {{ client_name }}OperationsMixin(object):
from {{ ".." if async_mode else "." }}{{ api }}{{ ".aio" if async_mode else "" }}.operations import {{ client_name }}OperationsMixin as OperationClass
{% endfor %}
else:
raise NotImplementedError("API version {} does not have operation '{{ operation_name }}'".format(api_version))
raise ValueError("API version {} does not have operation '{{ operation_name }}'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
6 changes: 3 additions & 3 deletions autorest/multiapi/templates/multiapi_service_client.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
base_url = {{ custom_base_url }}
{% endfor %}
else:
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
{% else %}
if not base_url:
base_url = {{ base_url }}
Expand Down Expand Up @@ -132,7 +132,7 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
from {{ relative_path }}{{ mod_api_version }} import models
return models
{% endfor %}
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
{% for operation_group, available_apis in operations|dictsort %}

@property
Expand All @@ -150,7 +150,7 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
from {{ relative_path }}{{ api[0] }}.{{ "aio." if async_mode else "" }}operations import {{ api[1] }} as OperationClass
{% endfor %}
else:
raise NotImplementedError("API version {} does not have operation group '{{ operation_group }}'".format(api_version))
raise ValueError("API version {} does not have operation group '{{ operation_group }}'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
{% endfor %}

Expand Down
2 changes: 1 addition & 1 deletion test/multiapi/AcceptanceTests/asynctests/multiapi_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def test_specificy_api_version_operation_mixin(self, client):
@pytest.mark.parametrize('api_version', ["3.0.0"])
@pytest.mark.asyncio
async def test_specify_api_version_with_no_mixin(self, client):
with pytest.raises(NotImplementedError):
with pytest.raises(ValueError):
await client.test_one(id=1, message="This should throw")

# OPERATION GROUP ONE
Expand Down
2 changes: 1 addition & 1 deletion test/multiapi/AcceptanceTests/multiapi_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_specificy_api_version_operation_mixin(self, client):

@pytest.mark.parametrize('api_version', ["3.0.0"])
def test_specify_api_version_with_no_mixin(self, client):
with pytest.raises(NotImplementedError):
with pytest.raises(ValueError):
client.test_one(id=1, message="This should throw")

# OPERATION GROUP ONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '3.0.0':
from .v3 import models
return models
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

@property
def operation_group_one(self):
Expand All @@ -112,7 +112,7 @@ def operation_group_one(self):
elif api_version == '3.0.0':
from .v3.operations import OperationGroupOneOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_one'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
Expand All @@ -128,7 +128,7 @@ def operation_group_two(self):
elif api_version == '3.0.0':
from .v3.operations import OperationGroupTwoOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_two'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def begin_test_lro(
if api_version == '1.0.0':
from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -84,7 +84,7 @@ def begin_test_lro_and_paging(
if api_version == '1.0.0':
from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_one(
elif api_version == '2.0.0':
from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_one'".format(api_version))
raise ValueError("API version {} does not have operation 'test_one'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand All @@ -138,7 +138,7 @@ def test_paging(
if api_version == '3.0.0':
from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'test_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '3.0.0':
from ..v3 import models
return models
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

@property
def operation_group_one(self):
Expand All @@ -112,7 +112,7 @@ def operation_group_one(self):
elif api_version == '3.0.0':
from ..v3.aio.operations import OperationGroupOneOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_one'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
Expand All @@ -128,7 +128,7 @@ def operation_group_two(self):
elif api_version == '3.0.0':
from ..v3.aio.operations import OperationGroupTwoOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_two'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

async def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def begin_test_lro(
if api_version == '1.0.0':
from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -80,7 +80,7 @@ def begin_test_lro_and_paging(
if api_version == '1.0.0':
from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -111,7 +111,7 @@ async def test_one(
elif api_version == '2.0.0':
from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_one'".format(api_version))
raise ValueError("API version {} does not have operation 'test_one'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand All @@ -134,7 +134,7 @@ def test_paging(
if api_version == '3.0.0':
from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'test_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '3.0.0':
from .v3 import models
return models
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

@property
def operation_group_one(self):
Expand All @@ -112,7 +112,7 @@ def operation_group_one(self):
elif api_version == '3.0.0':
from .v3.operations import OperationGroupOneOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_one'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
Expand All @@ -128,7 +128,7 @@ def operation_group_two(self):
elif api_version == '3.0.0':
from .v3.operations import OperationGroupTwoOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_two'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def begin_test_lro(
if api_version == '1.0.0':
from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -84,7 +84,7 @@ def begin_test_lro_and_paging(
if api_version == '1.0.0':
from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_one(
elif api_version == '2.0.0':
from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_one'".format(api_version))
raise ValueError("API version {} does not have operation 'test_one'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand All @@ -138,7 +138,7 @@ def test_paging(
if api_version == '3.0.0':
from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'test_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '3.0.0':
from ..v3 import models
return models
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

@property
def operation_group_one(self):
Expand All @@ -112,7 +112,7 @@ def operation_group_one(self):
elif api_version == '3.0.0':
from ..v3.aio.operations import OperationGroupOneOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_one'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
Expand All @@ -128,7 +128,7 @@ def operation_group_two(self):
elif api_version == '3.0.0':
from ..v3.aio.operations import OperationGroupTwoOperations as OperationClass
else:
raise NotImplementedError("API version {} does not have operation group 'operation_group_two'".format(api_version))
raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

async def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def begin_test_lro(
if api_version == '1.0.0':
from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -80,7 +80,7 @@ def begin_test_lro_and_paging(
if api_version == '1.0.0':
from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down Expand Up @@ -111,7 +111,7 @@ async def test_one(
elif api_version == '2.0.0':
from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_one'".format(api_version))
raise ValueError("API version {} does not have operation 'test_one'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand All @@ -134,7 +134,7 @@ def test_paging(
if api_version == '3.0.0':
from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test_paging'".format(api_version))
raise ValueError("API version {} does not have operation 'test_paging'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
elif api_version == '2.0.0':
base_url = '{Endpoint}/multiapiCustomBaseUrl/v2'
else:
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))
self._config = MultiapiCustomBaseUrlServiceClientConfiguration(credential, endpoint, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
super(MultiapiCustomBaseUrlServiceClient, self).__init__(
Expand All @@ -91,7 +91,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '2.0.0':
from .v2 import models
return models
raise NotImplementedError("API version {} is not available".format(api_version))
raise ValueError("API version {} is not available".format(api_version))

def close(self):
self._client.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test(
elif api_version == '2.0.0':
from .v2.operations import MultiapiCustomBaseUrlServiceClientOperationsMixin as OperationClass
else:
raise NotImplementedError("API version {} does not have operation 'test'".format(api_version))
raise ValueError("API version {} does not have operation 'test'".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance._config = self._config
Expand Down
Loading