Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve API version error #752

Merged
merged 3 commits into from
Sep 9, 2020
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
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Modelerfour version: 4.15.416
- Updated minimum `azure-core` version to 1.8.0 #747
- Updated minimum `msrest` version to 0.6.18 #747
- Support for `multipart/form-data` #746
- Better `NotImplementedError` thrown in multiapi case. Includes the name of the operation and operation group
in error that is thrown when an API version does not have that operation / operation group #752

**Bug fixes**

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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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
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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("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
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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("API version {} is not available".format(api_version))
self._config = MultiapiCustomBaseUrlServiceClientConfiguration(credential, endpoint, **kwargs)
self._client = AsyncPipelineClient(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("APIVersion {} is not available".format(api_version))
raise NotImplementedError("API version {} is not available".format(api_version))

async def close(self):
await self._client.close()
Expand Down
Loading