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 @@ -8,6 +8,7 @@ Modelerfour version: 4.13.351
- 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 type #656
- Fixed generation of pkgutil init files #661
- Have the next operation in a paging call use the HTTP verb GET if the next operation is not defined #664

### 2020-05-22 - 5.0.0-preview.8
Modelerfour version: 4.13.351
Expand Down
7 changes: 3 additions & 4 deletions autorest/codegen/templates/operation_tools.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ else:
{% endif %}
body_content_kwargs['content'] = body_content{% endmacro %}
{# write body parameters #}
{% macro body_parameters(operation) %}
{% macro body_parameters(operation, http_verb=None) %}
{% set send_xml = "xml" if operation.parameters.has_body and "xml" in operation.request_content_type %}
{% set request_as_xml = ", is_xml=True" if send_xml else "" %}
# Construct and send request
{% if operation.parameters.has_body %}
body_content_kwargs = {} # type: Dict[str, Any]
{% if (operation.requests | length) == 1 %}
Expand All @@ -202,6 +201,6 @@ else:
"{{ operation.requests | map(attribute="media_types") | sum(start = []) | unique | list }}".format(header_parameters['Content-Type'])
)
{% endif %}
request = self._client.{{ operation.method }}(url, query_parameters, header_parameters, **body_content_kwargs)
request = self._client.{{ http_verb if http_verb else operation.method }}(url, query_parameters, header_parameters, **body_content_kwargs)
{% else %}
request = self._client.{{ operation.method }}(url, query_parameters, header_parameters){% endif %}{% endmacro %}
request = self._client.{{ http_verb if http_verb else operation.method }}(url, query_parameters, header_parameters){% endif %}{% endmacro %}
6 changes: 4 additions & 2 deletions autorest/codegen/templates/paging_operation.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
{% endif %}

def prepare_request(next_link=None):
{{ op_tools.header_parameters(code_model, operation, async_mode)|indent(8) }}
if not next_link:
# Construct URL
url = self.{{ operation.python_name }}.metadata['url'] # type: ignore
Expand All @@ -74,6 +75,7 @@
url = self._client.format_url(url, **path_format_arguments)
{% endif %}
{{ op_tools.query_parameters(operation, async_mode)|indent(12) }}
{{ op_tools.body_parameters(operation)|indent(12) }}
else:
{% if operation.next_operation %}
url = '{{ operation.next_operation.url }}'
Expand All @@ -86,6 +88,7 @@
url = self._client.format_url(url, **path_format_arguments)
{% endif %}
{{ op_tools.query_parameters(operation.next_operation, async_mode)|indent(12) }}
{{ op_tools.body_parameters(operation.next_operation)|indent(12) }}
{% else %}
url = next_link
query_parameters = {} # type: Dict[str, Any]
Expand All @@ -97,9 +100,8 @@
}
url = self._client.format_url(url, **path_format_arguments)
{% endif %}
{{ op_tools.body_parameters(operation, http_verb="get")|indent(12) }}
{% endif %}
{{ op_tools.header_parameters(code_model, operation, async_mode)|indent(8) }}
{{ op_tools.body_parameters(operation)|indent(8) }}
return request

{{ keywords.def }} extract_data(pipeline_response):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def get_null(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -115,7 +115,7 @@ async def put_positive_duration(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

# Construct and send request
# Construct request
body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(duration_body, 'duration')
body_content_kwargs['content'] = body_content
Expand Down Expand Up @@ -160,7 +160,7 @@ async def get_positive_duration(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -204,7 +204,7 @@ async def get_invalid(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_null(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -121,7 +121,7 @@ def put_positive_duration(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

# Construct and send request
# Construct request
body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(duration_body, 'duration')
body_content_kwargs['content'] = body_content
Expand Down Expand Up @@ -167,7 +167,7 @@ def get_positive_duration(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -212,7 +212,7 @@ def get_invalid(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def post_required(
header_parameters['customHeader'] = self._serialize.header("custom_header", _custom_header, 'str')
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

# Construct and send request
# Construct request
body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(_body, 'int')
body_content_kwargs['content'] = body_content
Expand Down Expand Up @@ -145,7 +145,7 @@ async def post_optional(
if _custom_header is not None:
header_parameters['customHeader'] = self._serialize.header("custom_header", _custom_header, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -210,7 +210,7 @@ async def post_multi_param_groups(
if _header_two is not None:
header_parameters['header-two'] = self._serialize.header("header_two", _header_two, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -263,7 +263,7 @@ async def post_shared_parameter_group_object(
if _header_one is not None:
header_parameters['header-one'] = self._serialize.header("header_one", _header_one, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def post_required(
header_parameters['customHeader'] = self._serialize.header("custom_header", _custom_header, 'str')
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

# Construct and send request
# Construct request
body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(_body, 'int')
body_content_kwargs['content'] = body_content
Expand Down Expand Up @@ -151,7 +151,7 @@ def post_optional(
if _custom_header is not None:
header_parameters['customHeader'] = self._serialize.header("custom_header", _custom_header, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -217,7 +217,7 @@ def post_multi_param_groups(
if _header_two is not None:
header_parameters['header-two'] = self._serialize.header("header_two", _header_two, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -271,7 +271,7 @@ def post_shared_parameter_group_object(
if _header_one is not None:
header_parameters['header-one'] = self._serialize.header("header_one", _header_one, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def get_report(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_report(
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def get_method_global_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -110,7 +110,7 @@ async def get_method_global_not_provided_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -152,7 +152,7 @@ async def get_path_global_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -194,7 +194,7 @@ async def get_swagger_global_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def get_method_local_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -114,7 +114,7 @@ async def get_method_local_null(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -156,7 +156,7 @@ async def get_path_local_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -198,7 +198,7 @@ async def get_swagger_local_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def custom_named_request_id(
header_parameters = {} # type: Dict[str, Any]
header_parameters['foo-client-request-id'] = self._serialize.header("foo_client_request_id", foo_client_request_id, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -122,7 +122,7 @@ async def custom_named_request_id_param_grouping(
header_parameters = {} # type: Dict[str, Any]
header_parameters['foo-client-request-id'] = self._serialize.header("foo_client_request_id", _foo_client_request_id, 'str')

# Construct and send request
# Construct request
request = self._client.post(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -169,7 +169,7 @@ async def custom_named_request_id_head(
header_parameters = {} # type: Dict[str, Any]
header_parameters['foo-client-request-id'] = self._serialize.header("foo_client_request_id", foo_client_request_id, 'str')

# Construct and send request
# Construct request
request = self._client.head(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def get_with_filter(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def get_method_path_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -120,7 +120,7 @@ async def get_path_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -165,7 +165,7 @@ async def get_swagger_path_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -209,7 +209,7 @@ async def get_method_query_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -254,7 +254,7 @@ async def get_method_query_null(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -298,7 +298,7 @@ async def get_path_query_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down Expand Up @@ -340,7 +340,7 @@ async def get_swagger_query_valid(
# Construct headers
header_parameters = {} # type: Dict[str, Any]

# Construct and send request
# Construct request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
Expand Down
Loading