Skip to content

Commit

Permalink
just do get call to next link for single operation dpg paging (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Jun 17, 2022
1 parent 4497bc6 commit 7cd43fc
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 535 deletions.
18 changes: 11 additions & 7 deletions autorest/codegen/serializers/builder_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,16 @@ def call_next_link_request_builder(self, builder: PagingOperationType) -> List[s
template_url = "next_link"

request_builder = builder.next_request_builder or builder.request_builder
return self._call_request_builder_helper(
builder, request_builder, template_url=template_url, is_next_request=True
)
if builder.next_request_builder or self.code_model.is_legacy:
return self._call_request_builder_helper(
builder,
request_builder,
template_url=template_url,
is_next_request=True,
)
retval = ['request = HttpRequest("GET", next_link)']
retval.extend(self._postprocess_http_request(builder, "request.url"))
return retval

def _prepare_request_callback(self, builder: PagingOperationType) -> List[str]:
retval = ["def prepare_request(next_link=None):"]
Expand All @@ -1148,10 +1155,7 @@ def _prepare_request_callback(self, builder: PagingOperationType) -> List[str]:
retval.extend(
[f" {line}" for line in self.call_next_link_request_builder(builder)]
)
if not builder.next_request_builder and builder.parameters.path:
retval.append("")
retval.extend([f" {line}" for line in self.serialize_path(builder)])
if not builder.next_request_builder:
if not builder.next_request_builder and self.code_model.is_legacy:
retval.append(' request.method = "GET"')
else:
retval.append("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_basic_paging_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

def extract_data(pipeline_response):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_basic_paging_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ def prepare_request(next_link=None):
"host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore

path_format_arguments = {
"accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True),
"host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True),
}
request.method = "GET"
return request

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ def prepare_request(next_link=None):
"host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True),
}
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore

path_format_arguments = {
"accountName": self._serialize.url("account_name", account_name, "str", skip_quote=True),
"host": self._serialize.url("self._config.host", self._config.host, "str", skip_quote=True),
}
request.method = "GET"
return request

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_no_item_name_pages_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -184,13 +180,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_null_next_link_name_pages_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -253,13 +245,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_single_pages_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -323,13 +311,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_first_response_empty_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -410,16 +394,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_request(
client_request_id=client_request_id,
maxresults=maxresults,
timeout=timeout,
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -568,13 +545,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_duplicate_params_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -655,16 +628,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_odata_multiple_pages_request(
client_request_id=client_request_id,
maxresults=maxresults,
timeout=timeout,
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -749,17 +715,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_with_offset_request(
offset=offset,
client_request_id=client_request_id,
maxresults=maxresults,
timeout=timeout,
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -823,13 +781,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_retry_first_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -893,13 +847,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_retry_second_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -962,13 +912,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_single_pages_failure_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -1031,13 +977,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_failure_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -1100,13 +1042,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_failure_uri_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -1401,16 +1339,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_multiple_pages_lro_request(
client_request_id=client_request_id,
maxresults=maxresults,
timeout=timeout,
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down Expand Up @@ -1510,13 +1441,9 @@ def prepare_request(next_link=None):
request.url = self._client.format_url(request.url) # type: ignore

else:
request = HttpRequest("GET", next_link)
request.url = self._client.format_url(request.url) # type: ignore

request = build_paging_get_paging_model_with_item_name_with_xms_client_name_request(
headers=_headers,
params=_params,
)
request.url = self._client.format_url(next_link) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
Expand Down
Loading

0 comments on commit 7cd43fc

Please sign in to comment.