Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.
Merged

LLC #875

Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
6549ef5
temp
iscai-msft Jan 20, 2021
1b87d8e
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Jan 20, 2021
a78dc5d
split operation code into separate request object
iscai-msft Jan 21, 2021
647574d
generate request in separate method, passing vanilla
iscai-msft Jan 21, 2021
a790523
separate out response handling jinja code
iscai-msft Jan 22, 2021
50c486f
make work for lro
iscai-msft Jan 25, 2021
8a158f2
make work for paging
iscai-msft Jan 26, 2021
71e007f
fix response headers
iscai-msft Jan 27, 2021
0da9058
trying to find lro + paging differences
iscai-msft Jan 27, 2021
cecae05
fix lro + paging
iscai-msft Jan 27, 2021
0b6bb32
combine sync and async param method signatures
iscai-msft Jan 27, 2021
02921e4
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Jan 27, 2021
2005c06
duplicate parameters onto operation
iscai-msft Jan 27, 2021
a8a5089
make request parameters different
iscai-msft Jan 27, 2021
648b065
deal with flattening
iscai-msft Jan 27, 2021
b5e1b7a
fix multipart
iscai-msft Jan 28, 2021
be49a4d
fix multiple media types
iscai-msft Jan 28, 2021
5d14e43
grouping
iscai-msft Jan 28, 2021
982dd37
fix xml
iscai-msft Jan 28, 2021
7f5c2f2
fix multiapi
iscai-msft Jan 28, 2021
8f33e8e
make grouped params private in high level operation, public in request
iscai-msft Jan 28, 2021
879a8f3
pylint and mypy
iscai-msft Jan 28, 2021
1b97770
fix unittests
iscai-msft Jan 28, 2021
dfe3b73
fix operation spacing
iscai-msft Jan 28, 2021
0036595
allow users to pass in request url through template_url kwarg
iscai-msft Feb 2, 2021
d2dd25c
remove _body = _body
iscai-msft Feb 2, 2021
553c19f
add back lro initial operation
iscai-msft Feb 9, 2021
02fd740
merge autorestv3
iscai-msft Feb 9, 2021
4035381
fix type annotations for multiple media types
iscai-msft Feb 9, 2021
7d1d75b
remove added typing for kwargs in async
iscai-msft Feb 9, 2021
5f5c57c
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 9, 2021
9c515f8
fix pylint
iscai-msft Feb 9, 2021
93b1104
fix mypy
iscai-msft Feb 9, 2021
b5d606e
fix unittests
iscai-msft Feb 10, 2021
a90b361
fix media types
iscai-msft Feb 10, 2021
40c324e
fix multiple media types serialization
iscai-msft Feb 10, 2021
c4cbfe5
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 10, 2021
04caf48
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 10, 2021
ca14ed4
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 10, 2021
82e7647
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 11, 2021
6d8f1c2
remove comment about binary body params in multi media types
iscai-msft Feb 11, 2021
03c7b73
fix pylint
iscai-msft Feb 11, 2021
b8442ef
main operation passes url to request
iscai-msft Feb 11, 2021
8655bb4
serialize obj bodies before passing to request
iscai-msft Feb 12, 2021
1482c2b
fix so ops with one media type serialize body in main op
iscai-msft Feb 12, 2021
586f525
remove unnecessary content type inspection
iscai-msft Feb 12, 2021
7a6fb4b
don't serialize constant bodies in main op, serialize in request
iscai-msft Feb 12, 2021
4e6ec75
remove constant bodies from request
iscai-msft Feb 17, 2021
f31bbe4
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 24, 2021
c6d8525
request -> preparer
iscai-msft Feb 24, 2021
21ef574
request parameters to preparer parameters
iscai-msft Feb 24, 2021
0da4930
remove serialization of constant bodies in preparer
iscai-msft Feb 26, 2021
2d899d9
move preparers to protocol namespace (#902)
iscai-msft Mar 16, 2021
3b1e933
make next paging requests public
iscai-msft Mar 16, 2021
ab2f103
remove _request from preparer name
iscai-msft Mar 17, 2021
4b0df76
switch to protocol httprequest and httpresponse (#903)
iscai-msft Mar 19, 2021
7e810aa
add low-level-client flag
iscai-msft Mar 22, 2021
82c6da3
keep convenience layer working
iscai-msft Mar 23, 2021
48a4f0a
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Mar 23, 2021
8d3fb4c
add 'johan' flag
iscai-msft Mar 23, 2021
57d39fc
remove protocol and _protocol layers
iscai-msft Mar 23, 2021
089099b
add examples to send_request docstring
iscai-msft Mar 23, 2021
5e30834
add preparer docstrings
iscai-msft Mar 23, 2021
66df441
add preparer docstrings
iscai-msft Mar 24, 2021
813d39f
temp
iscai-msft Mar 24, 2021
bbe680f
sort out different body kwargs
iscai-msft Mar 24, 2021
fa8d7c2
gen multiple body params, works for llc
iscai-msft Mar 24, 2021
e5bcdb7
add content type tests
iscai-msft Mar 25, 2021
feae12d
add stream checkign request
iscai-msft Mar 26, 2021
62953b7
improve convenience layer generation for multiple media types + docst…
iscai-msft Mar 26, 2021
8fbf9cf
correct keyword docstrings to keyword and paramtype
iscai-msft Mar 26, 2021
d7b292d
preparer -> request builder
iscai-msft Mar 26, 2021
f74c668
fix ordering of method to be params then kwargs
iscai-msft Mar 26, 2021
d9bee54
make body kwargs optional
iscai-msft Mar 26, 2021
cda8703
url
iscai-msft Mar 26, 2021
825bf80
get internal request in send_request
iscai-msft Mar 30, 2021
e74e3dd
add most of vanilla test suite
iscai-msft Mar 30, 2021
1e987f0
always generate serializer
iscai-msft Apr 5, 2021
1dce813
add vendor flag
iscai-msft Apr 5, 2021
e2ba64a
Merge branch 'prepare_request' of https://github.com/Azure/autorest.p…
iscai-msft Apr 5, 2021
68b2e5c
add streaming
iscai-msft Apr 7, 2021
f449582
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Apr 8, 2021
0a71bec
temp
iscai-msft Apr 8, 2021
d39ea93
temp
iscai-msft Apr 14, 2021
0276805
move operation group name to submodule of rest
iscai-msft Apr 15, 2021
8b51709
do reading inside send_request
iscai-msft Apr 16, 2021
4a8dedd
generate with new rest structure and start fixing tests
iscai-msft Apr 19, 2021
68f4da3
temp
iscai-msft Apr 20, 2021
dcbe84d
start azure llc tests
iscai-msft Apr 20, 2021
9d70b30
clean up code
iscai-msft Apr 23, 2021
bb3837e
switch to passing pipeline to stream context manager
iscai-msft Apr 23, 2021
624a5e7
temp
iscai-msft Apr 26, 2021
009713e
generate with response json output template
iscai-msft Apr 28, 2021
f2329b0
no models
iscai-msft Apr 29, 2021
8505ff2
work on connection between convenience layer + rest layer
iscai-msft Apr 29, 2021
b028893
get farmbeats working
iscai-msft Apr 30, 2021
bc1bbfc
improve json input template
iscai-msft May 3, 2021
df21b4d
improve json templating
iscai-msft May 4, 2021
53d73bd
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft May 4, 2021
0d72b79
temp
iscai-msft May 7, 2021
dff7fb1
rename llc aka link
iscai-msft May 11, 2021
b085c97
improve serializers
iscai-msft May 12, 2021
70fd3b5
fix lro paging generation
iscai-msft May 12, 2021
6de4c82
change test generation
iscai-msft May 12, 2021
843bea3
Merge branch 'improve_serializers' of https://github.com/Azure/autore…
iscai-msft May 12, 2021
602e240
move template code to serializers
iscai-msft May 13, 2021
b97532e
add serializers
iscai-msft Jun 1, 2021
c063011
temp
iscai-msft Jun 7, 2021
ba50ed8
most vanilla passing
iscai-msft Jun 7, 2021
b3cb391
temp
iscai-msft Jun 10, 2021
37580b8
temp to generate synapse
iscai-msft Jun 16, 2021
3a5efc4
temp
iscai-msft Jun 21, 2021
78aef80
sync vanilla passing besides formdata
iscai-msft Jun 22, 2021
26630dd
switch _rest to rest
iscai-msft Jun 23, 2021
608ad98
make llc and legacy sections of vanilla test
iscai-msft Jun 23, 2021
50dc877
make send_request in async without async def
iscai-msft Jun 24, 2021
3328993
make async send_request not have async function header, regenerated v…
iscai-msft Jun 25, 2021
b0edf6c
make azure legacy folder, all but storage generating
iscai-msft Jun 29, 2021
d97bc6e
vanilla llc passing
iscai-msft Jul 6, 2021
ed9270a
temp
iscai-msft Jul 6, 2021
77b1d62
azure tests passing
iscai-msft Jul 6, 2021
a8115b6
switch make_request fixture to send_request
iscai-msft Jul 7, 2021
98c9ea5
temp
iscai-msft Jul 8, 2021
edca270
all azure vanilla tests passing
iscai-msft Jul 8, 2021
b559dc5
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Jul 8, 2021
6e65899
revert multiapi to version in autorestv3 branch
iscai-msft Jul 8, 2021
fbda5bf
multiapi generating
iscai-msft Jul 8, 2021
12bca7d
Disable LLC and M4 conflicts
lmazuel Jul 8, 2021
a061c91
regen without PipelineTransportHttpRequest import
iscai-msft Jul 8, 2021
3cbc5b8
regen with new show flags
iscai-msft Jul 8, 2021
1e602c4
improve send_request docstring, allow send_request to be private
iscai-msft Jul 8, 2021
b7b73d8
regen
iscai-msft Jul 9, 2021
c0965d4
fix whitespace
iscai-msft Jul 9, 2021
9046573
lint and mypy wip
iscai-msft Jul 9, 2021
12bef9d
Merge branch 'llc_m4_flags' of https://github.com/Azure/autorest.pyth…
iscai-msft Jul 9, 2021
eb7b77d
regenerate without flattening
iscai-msft Jul 12, 2021
5587303
generate and run llc update tests
iscai-msft Jul 12, 2021
a48bc81
regenerate all again without flattening / grouping
iscai-msft Jul 12, 2021
c244152
lint and mypy
iscai-msft Jul 12, 2021
03aed7b
add llc steps
iscai-msft Jul 12, 2021
6abe67d
fix circular imports
iscai-msft Jul 12, 2021
45b4ee1
fix unittests
iscai-msft Jul 12, 2021
c8c929f
add tox for update tests, move tox.ini for legacy and llc
iscai-msft Jul 12, 2021
940898e
fix generation of json templates
iscai-msft Jul 12, 2021
4d8e09d
don't generate templates if not exposing rest layer
iscai-msft Jul 12, 2021
d45a845
fix missing http_response declaration
iscai-msft Jul 12, 2021
be7018e
lint
iscai-msft Jul 12, 2021
9b2ce27
switch to testing 3.6 instead of 3.5
iscai-msft Jul 12, 2021
70e0dbc
fix testserver starting in conftest
iscai-msft Jul 12, 2021
cc0123f
fix azure llc testserver starting
iscai-msft Jul 12, 2021
6b9eaf3
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Jul 12, 2021
9e6383d
remove vendor flag
iscai-msft Jul 12, 2021
64cf1ca
fix param grouping tests
iscai-msft Jul 13, 2021
4fc2f1a
add model flattening tests
iscai-msft Jul 13, 2021
2130ab0
fix send_request tests in legacy
iscai-msft Jul 13, 2021
9901ce6
fix flag and update changelog
iscai-msft Jul 13, 2021
b29fcfc
fix param groupign tests
iscai-msft Jul 13, 2021
2b4e52e
add coverage for LLC update tests
iscai-msft Jul 13, 2021
75e5371
try vanilla llc coverage
iscai-msft Jul 13, 2021
5e8b87e
pylint
iscai-msft Jul 13, 2021
11339e3
add coverage for llc
iscai-msft Jul 13, 2021
61409d9
don't black generic request builder file bc of trailing comma
iscai-msft Jul 13, 2021
3236278
fix lro test call to correct request
iscai-msft Jul 13, 2021
803e9cc
remove unnecessary ParameterType typevar
iscai-msft Jul 13, 2021
caae78b
pylint
iscai-msft Jul 13, 2021
e801651
add conftest in each acceptance tests folder vanilla llc
iscai-msft Jul 13, 2021
55fbdb3
fix relative path to testserver in vanilla conftests
iscai-msft Jul 13, 2021
51f578c
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Jul 13, 2021
1e70958
pad private variables for LLC
iscai-msft Jul 14, 2021
067d76e
add llc param grouping with reserved word test
iscai-msft Jul 14, 2021
8235624
don't force flags in llc mode
iscai-msft Jul 14, 2021
c6c1011
make fixes after talking with laurent
iscai-msft Jul 14, 2021
c8569cd
skip all llc coverage in legacy tests
iscai-msft Jul 14, 2021
d3a7e0c
fix pylint
iscai-msft Jul 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion autorest/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def _create_code_model(self, yaml_data: Dict[str, Any], options: Dict[str, Union
code_model.generate_single_parameter_from_multiple_media_types()

# LRO operation
code_model.format_lro_operations()
code_model.remove_next_operation()

if options["credential"]:
Expand Down
2 changes: 2 additions & 0 deletions autorest/codegen/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .operation_group import OperationGroup
from .schema_response import SchemaResponse
from .parameter_list import ParameterList
from .request import Request


__all__ = [
Expand All @@ -46,6 +47,7 @@
"ParameterList",
"OperationGroup",
"Property",
"Request",
"SchemaResponse",
"TokenCredentialSchema",
]
Expand Down
48 changes: 8 additions & 40 deletions autorest/codegen/models/code_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,40 +143,6 @@ def add_credential_global_parameter(self) -> None:
)
self.global_parameters.insert(0, credential_parameter)

@staticmethod
def _lro_initial_function(operation: LROOperation) -> Operation:
return Operation(
yaml_data={},
name="_" + operation.name + "_initial",
description="",
url=operation.url,
method=operation.method,
multipart=operation.multipart,
api_versions=operation.api_versions,
parameters=operation.parameters.parameters,
requests=operation.requests,
responses=operation.responses,
exceptions=operation.exceptions,
want_description_docstring=False,
want_tracing=False,
)

def format_lro_operations(self) -> None:
"""Adds operations and attributes needed for LROs.

If there are LRO functions in here, will add initial LRO function. Will also set the return
type of the LRO operation
"""
for operation_group in self.operation_groups:
i = 0
while i < len(operation_group.operations):
operation = operation_group.operations[i]
if isinstance(operation, LROOperation):
operation.set_lro_response_type()
operation_group.operations.insert(i, CodeModel._lro_initial_function(operation))
i += 1
i += 1

def remove_next_operation(self) -> None:
"""Linking paging operations together.
"""
Expand Down Expand Up @@ -302,11 +268,12 @@ def add_schema_link_to_operation(self) -> None:
for operation in operation_group.operations:
for obj in chain(
operation.parameters,
operation.multiple_media_type_parameters or [],
operation.request.parameters,
operation.request.multiple_media_type_parameters or [],
operation.responses,
operation.exceptions,
chain.from_iterable(response.headers for response in operation.responses),
chain.from_iterable(request.parameters for request in operation.requests)
chain.from_iterable(request.parameters for request in operation.request.schema_requests)
):
self._populate_schema(obj)

Expand All @@ -317,15 +284,16 @@ def add_schema_link_to_global_parameters(self) -> None:
def generate_single_parameter_from_multiple_media_types(self) -> None:
for operation_group in self.operation_groups:
for operation in operation_group.operations:
if operation.multiple_media_type_parameters:
if operation.request.multiple_media_type_parameters:
type_annot = ", ".join([
param.schema.operation_type_annotation for param in operation.multiple_media_type_parameters
param.schema.operation_type_annotation
for param in operation.request.multiple_media_type_parameters
])
docstring_type = " or ".join([
param.schema.docstring_type for param in operation.multiple_media_type_parameters
param.schema.docstring_type for param in operation.request.multiple_media_type_parameters
])
chosen_parameter = next(
iter(filter(lambda x: x.has_multiple_media_types, operation.parameters)), None
iter(filter(lambda x: x.has_multiple_media_types, operation.request.parameters)), None
)
if not chosen_parameter:
raise ValueError("You are missing a parameter that has multiple media types")
Expand Down
25 changes: 10 additions & 15 deletions autorest/codegen/models/lro_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .operation import Operation
from .parameter import Parameter
from .schema_response import SchemaResponse
from .schema_request import SchemaRequest
from .request import Request
from .imports import ImportType, TypingSection
from .base_schema import BaseSchema

Expand All @@ -20,44 +20,39 @@ class LROOperation(Operation):
def __init__(
self,
yaml_data: Dict[str, Any],
request: Request,
name: str,
description: str,
url: str,
method: str,
multipart: bool,
api_versions: Set[str],
requests: List[SchemaRequest],
summary: Optional[str] = None,
parameters: Optional[List[Parameter]] = None,
multiple_media_type_parameters: Optional[List[Parameter]] = None,
summary: Optional[str] = None,
responses: Optional[List[SchemaResponse]] = None,
exceptions: Optional[List[SchemaResponse]] = None,
want_description_docstring: bool = True,
want_tracing: bool = True
) -> None:
super(LROOperation, self).__init__(
yaml_data,
request,
name,
description,
url,
method,
multipart,
api_versions,
requests,
summary,
parameters,
multiple_media_type_parameters,
summary,
responses,
exceptions,
want_description_docstring,
want_tracing,
)
self.lro_response: Optional[SchemaResponse] = None
self.lro_options = yaml_data.get("extensions", {}).get("x-ms-long-running-operation-options", {})
self.name = "begin_" + self.name

def set_lro_response_type(self) -> None:
@property
def lro_response(self) -> Optional[SchemaResponse]:
if not self.responses:
return
return None
responses_with_bodies = [r for r in self.responses if r.has_body]
num_response_schemas = {r.schema for r in responses_with_bodies}
response = None
Expand All @@ -81,7 +76,7 @@ def set_lro_response_type(self) -> None:

elif num_response_schemas:
response = responses_with_bodies[0]
self.lro_response = response
return response

@property
def has_optional_return_type(self) -> bool:
Expand Down
48 changes: 6 additions & 42 deletions autorest/codegen/models/lro_paging_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,11 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

from typing import Any, Dict, List, Set, Optional
from .imports import FileImport
from .lro_operation import LROOperation
from .paging_operation import PagingOperation
from .imports import FileImport
from .schema_request import SchemaRequest
from .parameter import Parameter
from .schema_response import SchemaResponse

class LROPagingOperation(PagingOperation, LROOperation):
def __init__(
self,
yaml_data: Dict[str, Any],
name: str,
description: str,
url: str,
method: str,
multipart: bool,
api_versions: Set[str],
requests: List[SchemaRequest],
summary: Optional[str] = None,
parameters: Optional[List[Parameter]] = None,
multiple_media_type_parameters: Optional[List[Parameter]] = None,
responses: Optional[List[SchemaResponse]] = None,
exceptions: Optional[List[SchemaResponse]] = None,
want_description_docstring: bool = True,
want_tracing: bool = True
) -> None:
super(LROPagingOperation, self).__init__(
yaml_data,
name,
description,
url,
method,
multipart,
api_versions,
requests,
summary,
parameters,
multiple_media_type_parameters,
responses,
exceptions,
want_description_docstring,
want_tracing,
override_success_response_to_200=True
)

def imports(self, code_model, async_mode: bool) -> FileImport:
lro_imports = LROOperation.imports(self, code_model, async_mode)
Expand All @@ -57,3 +16,8 @@ def imports(self, code_model, async_mode: bool) -> FileImport:
file_import = lro_imports
file_import.merge(paging_imports)
return file_import

@property
def paging_success_status_code(self):
# hardcode paging's success status code in lro + paging to be 200
return [200]
Loading