From b58b108da1fd1f95975db1bd5baf9ce969235d2f Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Fri, 15 Oct 2021 17:11:32 -0700 Subject: [PATCH] fix and add test for data bodies (#1061) --- ChangeLog.md | 14 ++ autorest/codegen/models/base_schema.py | 2 +- autorest/codegen/models/constant_schema.py | 4 +- autorest/codegen/models/credential_schema.py | 2 +- autorest/codegen/models/dictionary_schema.py | 4 +- autorest/codegen/models/enum_schema.py | 4 +- autorest/codegen/models/list_schema.py | 4 +- autorest/codegen/models/object_schema.py | 4 +- autorest/codegen/models/parameter.py | 7 +- autorest/codegen/models/parameter_list.py | 53 ++++-- autorest/codegen/models/primitive_schemas.py | 2 +- autorest/codegen/models/property.py | 4 +- .../models/request_builder_parameter.py | 2 +- .../models/request_builder_parameter_list.py | 14 +- .../codegen/serializers/builder_serializer.py | 81 ++++++--- package.json | 2 +- tasks.py | 1 + .../asynctests/test_urlencoded.py | 44 +++++ .../legacy/AcceptanceTests/test_urlencoded.py | 43 +++++ .../legacy/AcceptanceTests/test_zzz.py | 4 +- .../aio/operations/_formdata_operations.py | 6 - .../operations/_formdata_operations.py | 6 - .../bodyformurlencodeddata/__init__.py | 20 +++ .../_body_forms_data_url_encoded.py | 90 ++++++++++ .../bodyformurlencodeddata/_configuration.py | 49 ++++++ .../bodyformurlencodeddata/_vendor.py | 27 +++ .../bodyformurlencodeddata/_version.py | 9 + .../bodyformurlencodeddata/aio/__init__.py | 11 ++ .../aio/_body_forms_data_url_encoded.py | 72 ++++++++ .../aio/_configuration.py | 39 +++++ .../aio/operations/__init__.py | 13 ++ .../_formdataurlencoded_operations.py | 120 ++++++++++++++ .../bodyformurlencodeddata/models/__init__.py | 25 +++ .../_body_forms_data_url_encoded_enums.py | 27 +++ .../bodyformurlencodeddata/models/_models.py | 69 ++++++++ .../models/_models_py3.py | 82 +++++++++ .../operations/__init__.py | 13 ++ .../_formdataurlencoded_operations.py | 155 ++++++++++++++++++ .../bodyformurlencodeddata/py.typed | 1 + .../BodyFormUrlEncodedData/setup.py | 37 +++++ test/vanilla/legacy/requirements.txt | 1 + .../asynctests/test_urlencoded.py | 53 ++++++ .../AcceptanceTests/test_urlencoded.py | 52 ++++++ .../low-level/AcceptanceTests/test_zzz.py | 4 +- ...auto_rest_swagger_bat_form_data_service.py | 2 +- ...auto_rest_swagger_bat_form_data_service.py | 2 +- .../rest/formdata/_request_builders.py | 24 +-- .../rest/formdata/_request_builders_py3.py | 36 +--- .../__init__.py | 20 +++ .../_body_forms_data_url_encoded.py | 85 ++++++++++ .../_configuration.py | 49 ++++++ .../bodyformurlencodeddatalowlevel/_vendor.py | 17 ++ .../_version.py | 9 + .../aio/__init__.py | 11 ++ .../aio/_body_forms_data_url_encoded.py | 71 ++++++++ .../aio/_configuration.py | 39 +++++ .../bodyformurlencodeddatalowlevel/py.typed | 1 + .../rest/__init__.py | 6 + .../rest/formdataurlencoded/__init__.py | 16 ++ .../formdataurlencoded/_request_builders.py | 81 +++++++++ .../_request_builders_py3.py | 69 ++++++++ .../BodyFormUrlEncodedDataLowLevel/setup.py | 37 +++++ .../low-level/coverage/report-optional.json | 2 +- test/vanilla/low-level/requirements.txt | 1 + .../asynctests/test_urlencoded.py | 45 +++++ .../AcceptanceTests/test_urlencoded.py | 44 +++++ .../AcceptanceTests/test_zzz.py | 4 +- .../aio/operations/_operations.py | 8 - .../operations/_operations.py | 8 - .../__init__.py | 20 +++ .../_body_forms_data_url_encoded.py | 89 ++++++++++ .../_configuration.py | 49 ++++++ .../_vendor.py | 17 ++ .../_version.py | 9 + .../aio/__init__.py | 11 ++ .../aio/_body_forms_data_url_encoded.py | 75 +++++++++ .../aio/_configuration.py | 39 +++++ .../aio/operations/__init__.py | 13 ++ .../aio/operations/_operations.py | 99 +++++++++++ .../operations/__init__.py | 13 ++ .../operations/_operations.py | 140 ++++++++++++++++ .../py.typed | 1 + .../setup.py | 37 +++++ .../coverage/report-optional.json | 2 +- .../vanilla/version-tolerant/requirements.txt | 1 + 85 files changed, 2423 insertions(+), 155 deletions(-) create mode 100644 test/vanilla/legacy/AcceptanceTests/asynctests/test_urlencoded.py create mode 100644 test/vanilla/legacy/AcceptanceTests/test_urlencoded.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/__init__.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_configuration.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_version.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/__init__.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_configuration.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/__init__.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/__init__.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_body_forms_data_url_encoded_enums.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models_py3.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/__init__.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/py.typed create mode 100644 test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/setup.py create mode 100644 test/vanilla/low-level/AcceptanceTests/asynctests/test_urlencoded.py create mode 100644 test/vanilla/low-level/AcceptanceTests/test_urlencoded.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/__init__.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_configuration.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_vendor.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_version.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/__init__.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_configuration.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/py.typed create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/__init__.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/__init__.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders_py3.py create mode 100644 test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/setup.py create mode 100644 test/vanilla/version-tolerant/AcceptanceTests/asynctests/test_urlencoded.py create mode 100644 test/vanilla/version-tolerant/AcceptanceTests/test_urlencoded.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/__init__.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_configuration.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_vendor.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_version.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/__init__.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_body_forms_data_url_encoded.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_configuration.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/__init__.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/_operations.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/__init__.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/_operations.py create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/py.typed create mode 100644 test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/setup.py diff --git a/ChangeLog.md b/ChangeLog.md index 485146f6931..e4a706a08b3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,19 @@ # Change Log +### 2021-10-15 - 5.9.3 + +| Library | Min Version +| --------------- | ------- +|`@autorest/core` | `3.6.2` +|`@autorest/modelerfour` | `4.19.1` +|`azure-core` dep of generated code | `1.19.0` +|`msrest` dep of generated code | `0.6.21` +|`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` + +**Bug Fixes** + +- Fix generation of form-data inputs #1061 + ### 2021-10-05 - 5.9.2 | Library | Min Version diff --git a/autorest/codegen/models/base_schema.py b/autorest/codegen/models/base_schema.py index 8081bc14c45..6b1e2a17427 100644 --- a/autorest/codegen/models/base_schema.py +++ b/autorest/codegen/models/base_schema.py @@ -137,6 +137,6 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: ... @abstractmethod - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: """Template of what this schema would look like as files input""" ... diff --git a/autorest/codegen/models/constant_schema.py b/autorest/codegen/models/constant_schema.py index 64fbd0e3b76..1b8a5a40f45 100644 --- a/autorest/codegen/models/constant_schema.py +++ b/autorest/codegen/models/constant_schema.py @@ -87,9 +87,9 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: kwargs['default_value_declaration'] = self.schema.get_declaration(self.value) return self.schema.get_json_template_representation(**kwargs) - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: kwargs['default_value_declaration'] = self.schema.get_declaration(self.value) - return self.schema.get_files_template_representation(**kwargs) + return self.schema.get_files_and_data_template_representation(**kwargs) def imports(self) -> FileImport: file_import = FileImport() diff --git a/autorest/codegen/models/credential_schema.py b/autorest/codegen/models/credential_schema.py index 5eaa6da2bd0..671bd5edd8c 100644 --- a/autorest/codegen/models/credential_schema.py +++ b/autorest/codegen/models/credential_schema.py @@ -28,7 +28,7 @@ def serialization_type(self) -> str: def get_json_template_representation(self, **kwargs: Any) -> Any: raise TypeError("You should not try to get a JSON template representation of a CredentialSchema") - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: raise TypeError("You should not try to get a files template representation of a CredentialSchema") diff --git a/autorest/codegen/models/dictionary_schema.py b/autorest/codegen/models/dictionary_schema.py index 114dc7c00e6..39faf3c0b50 100644 --- a/autorest/codegen/models/dictionary_schema.py +++ b/autorest/codegen/models/dictionary_schema.py @@ -67,9 +67,9 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: f'"{"str"}"' : self.element_type.get_json_template_representation(**kwargs) } - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: return { - f'"{"str"}"' : self.element_type.get_files_template_representation(**kwargs) + f'"{"str"}"' : self.element_type.get_files_and_data_template_representation(**kwargs) } @classmethod diff --git a/autorest/codegen/models/enum_schema.py b/autorest/codegen/models/enum_schema.py index 0e71942ff44..92139ffb3e8 100644 --- a/autorest/codegen/models/enum_schema.py +++ b/autorest/codegen/models/enum_schema.py @@ -143,8 +143,8 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: # for better display effect, use the only value instead of var type return self.enum_type.get_json_template_representation(**self._template_kwargs(**kwargs)) - def get_files_template_representation(self, **kwargs: Any) -> Any: - return self.enum_type.get_files_template_representation(**self._template_kwargs(**kwargs)) + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: + return self.enum_type.get_files_and_data_template_representation(**self._template_kwargs(**kwargs)) @classmethod def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs: Any) -> "EnumSchema": diff --git a/autorest/codegen/models/list_schema.py b/autorest/codegen/models/list_schema.py index 332e50275e5..466653a0255 100644 --- a/autorest/codegen/models/list_schema.py +++ b/autorest/codegen/models/list_schema.py @@ -64,8 +64,8 @@ def has_xml_serialization_ctxt(self) -> bool: def get_json_template_representation(self, **kwargs: Any) -> Any: return [self.element_type.get_json_template_representation(**kwargs)] - def get_files_template_representation(self, **kwargs: Any) -> Any: - return [self.element_type.get_files_template_representation(**kwargs)] + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: + return [self.element_type.get_files_and_data_template_representation(**kwargs)] def xml_serialization_ctxt(self) -> Optional[str]: attrs_list = [] diff --git a/autorest/codegen/models/object_schema.py b/autorest/codegen/models/object_schema.py index c4fbd320d83..23f872df895 100644 --- a/autorest/codegen/models/object_schema.py +++ b/autorest/codegen/models/object_schema.py @@ -103,14 +103,14 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: self._created_json_template_representation = False return representation - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: object_schema_names = kwargs.get("object_schema_names", []) object_schema_names.append(self.name) # do tis to avoid circular kwargs["object_schema_names"] = object_schema_names return { "{}".format( prop.original_swagger_name - ): prop.get_files_template_representation(**kwargs) + ): prop.get_files_and_data_template_representation(**kwargs) for prop in self.properties } diff --git a/autorest/codegen/models/parameter.py b/autorest/codegen/models/parameter.py index 07b0c105787..0d839e540ad 100644 --- a/autorest/codegen/models/parameter.py +++ b/autorest/codegen/models/parameter.py @@ -88,8 +88,9 @@ def __init__( self.has_multiple_media_types: bool = False self.multiple_media_types_type_annot: Optional[str] = None self.multiple_media_types_docstring_type: Optional[str] = None - self.is_partial_body = yaml_data.get("isPartialBody", False) self._keyword_only = keyword_only + self.is_multipart = yaml_data.get("language", {}).get("python", {}).get("multipart", False) + self.is_data_input = yaml_data.get("isPartialBody", False) and not self.is_multipart def __hash__(self) -> int: return hash(self.serialized_name) @@ -123,10 +124,6 @@ def constant(self) -> bool: return False return self.required - @property - def is_multipart(self) -> bool: - return self.yaml_data["language"]["python"].get("multipart", False) - @property def constant_declaration(self) -> str: if self.schema: diff --git a/autorest/codegen/models/parameter_list.py b/autorest/codegen/models/parameter_list.py index b942f3fa258..3f5cfc00930 100644 --- a/autorest/codegen/models/parameter_list.py +++ b/autorest/codegen/models/parameter_list.py @@ -146,8 +146,8 @@ def multipart(self) -> List[Parameter]: return self.get_from_predicate(lambda parameter: parameter.is_multipart) @property - def has_partial_body(self) -> bool: - return any(self.get_from_predicate(lambda parameter: parameter.is_partial_body)) + def data_inputs(self) -> List[Parameter]: + return self.get_from_predicate(lambda parameter: parameter.is_data_input) @property def content_types(self) -> List[str]: @@ -278,32 +278,53 @@ def call(self) -> List[str]: def is_flattened(self) -> bool: return cast(bool, self.get_from_predicate(lambda parameter: parameter.flattened)) +def _create_files_or_data_param( + params: List[Parameter], serialized_name: str, description: str +) -> Parameter: + param = copy(params[0]) + param.serialized_name = serialized_name + param.schema = DictionarySchema( + namespace="", + yaml_data={}, + element_type=AnySchema(namespace="", yaml_data={}), + ) + param.description = description + return param + class ParameterOnlyPathAndBodyPositionalList(ParameterList): - # use this to change the files parameter in the method + # use this to change the files and data parameter in the method @property def method(self) -> List[Parameter]: method_params = super().method files_params = [p for p in method_params if p.is_multipart] - if not files_params: + data_params = [p for p in method_params if p.is_data_input] + if not (files_params or data_params): return method_params - files_param = copy(files_params[0]) - files_param.serialized_name = "files" - files_param.schema = DictionarySchema( - namespace="", - yaml_data={}, - element_type=AnySchema(namespace="", yaml_data={}), - ) - files_param.description = ( - "Multipart input for files. See the template in our example to find the input shape." - ) - method_params = [p for p in method_params if not p.is_multipart] + + # update files param + file_and_data_params = [] + if files_params: + files_param = _create_files_or_data_param( + files_params, + serialized_name="files", + description="Multipart input for files. See the template in our example to find the input shape." + ) + file_and_data_params.append(files_param) + if data_params: + data_param = _create_files_or_data_param( + data_params, + serialized_name="data", + description="Form-encoded input for data. See the template in our example to find the input shape." + ) + file_and_data_params.append(data_param) + method_params = [p for p in method_params if not p.is_multipart and not p.is_data_input] positional = [p for p in method_params if p.is_positional] keyword_only = [p for p in method_params if p.is_keyword_only] kwargs = self._filter_out_multiple_content_type( [p for p in method_params if p.is_kwarg] ) - return positional + [files_param] + keyword_only + kwargs + return positional + file_and_data_params + keyword_only + kwargs def get_parameter_list(code_model): if code_model.options["only_path_and_body_params_positional"]: diff --git a/autorest/codegen/models/primitive_schemas.py b/autorest/codegen/models/primitive_schemas.py index c00ce01e3c7..1d5d8c5dcc7 100644 --- a/autorest/codegen/models/primitive_schemas.py +++ b/autorest/codegen/models/primitive_schemas.py @@ -81,7 +81,7 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: def default_template_representation_declaration(self) -> str: return self.get_declaration(self.docstring_type) - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: """Template of what the files input should look like """ return self._add_optional_and_default_value_template_representation( diff --git a/autorest/codegen/models/property.py b/autorest/codegen/models/property.py index 2d7ae168ebf..c31527cfd42 100644 --- a/autorest/codegen/models/property.py +++ b/autorest/codegen/models/property.py @@ -163,9 +163,9 @@ def get_json_template_representation(self, **kwargs: Any) -> Any: kwargs["description"] = self.description return self.schema.get_json_template_representation(**kwargs) - def get_files_template_representation(self, **kwargs: Any) -> Any: + def get_files_and_data_template_representation(self, **kwargs: Any) -> Any: kwargs["optional"] = not self.required - return self.schema.get_files_template_representation(**kwargs) + return self.schema.get_files_and_data_template_representation(**kwargs) def model_file_imports(self) -> FileImport: file_import = self.schema.model_file_imports() diff --git a/autorest/codegen/models/request_builder_parameter.py b/autorest/codegen/models/request_builder_parameter.py index 87b2b1a0a44..6f38661377e 100644 --- a/autorest/codegen/models/request_builder_parameter.py +++ b/autorest/codegen/models/request_builder_parameter.py @@ -29,7 +29,7 @@ def name_in_high_level_operation(self) -> str: if self.is_body: if self.is_multipart: return "files" - if self.is_partial_body: + if self.is_data_input: return "data" return "json" name = self.yaml_data["language"]["python"]["name"] diff --git a/autorest/codegen/models/request_builder_parameter_list.py b/autorest/codegen/models/request_builder_parameter_list.py index 30f673167bc..eada56d9e06 100644 --- a/autorest/codegen/models/request_builder_parameter_list.py +++ b/autorest/codegen/models/request_builder_parameter_list.py @@ -42,10 +42,6 @@ def add_body_kwargs(self, schema_requests: List[SchemaRequest]) -> None: except StopIteration: pass else: - if body_method_param.constant: - # we don't add body kwargs for constant bodies - body_method_param.serialized_name = "json" - return if body_method_param.is_multipart: file_kwarg = copy(body_method_param) self._change_body_param_name(file_kwarg, "files") @@ -58,8 +54,9 @@ def add_body_kwargs(self, schema_requests: List[SchemaRequest]) -> None: "Multipart input for files. See the template in our example to find the input shape. " + file_kwarg.description ) + file_kwarg.is_multipart = False body_kwargs_added.append(file_kwarg) - if body_method_param.is_partial_body: + if body_method_param.is_data_input: data_kwarg = copy(body_method_param) self._change_body_param_name(data_kwarg, "data") data_kwarg.schema = DictionarySchema( @@ -71,7 +68,12 @@ def add_body_kwargs(self, schema_requests: List[SchemaRequest]) -> None: "Pass in dictionary that contains form data to include in the body of the request. " + data_kwarg.description ) + data_kwarg.is_data_input = False body_kwargs_added.append(data_kwarg) + if body_method_param.constant: + # we don't add body kwargs for constant bodies + body_method_param.serialized_name = "json" + return if ( any(sr for sr in schema_requests if not sr.is_stream_request) and any([ct for ct in self.content_types if "json" in ct]) @@ -93,6 +95,8 @@ def add_body_kwargs(self, schema_requests: List[SchemaRequest]) -> None: "a byte iterator, or stream input). " + content_kwarg.description ) + content_kwarg.is_data_input = False + content_kwarg.is_multipart = False body_kwargs_added.append(content_kwarg) if len(body_kwargs_added) == 1: body_kwargs_added[0].required = body_method_param.required diff --git a/autorest/codegen/serializers/builder_serializer.py b/autorest/codegen/serializers/builder_serializer.py index f9bbda3db90..51f4e9cbe2c 100644 --- a/autorest/codegen/serializers/builder_serializer.py +++ b/autorest/codegen/serializers/builder_serializer.py @@ -9,6 +9,7 @@ from collections import defaultdict from abc import abstractmethod, ABC from typing import Any, List, TypeVar, Dict, Union, Optional, cast + from ..models import ( Operation, CodeModel, @@ -52,10 +53,10 @@ def _json_dumps_template(template_representation: Any) -> Any: # only for template use, since it wraps everything in strings return _improve_json_string(json.dumps(template_representation, sort_keys=True, indent=4)) -def _serialize_files_dict(multipart_parameters: List[Parameter]) -> str: +def _serialize_files_or_data_dict(multipart_parameters: List[Parameter]) -> str: # only for template use template = { - param.serialized_name: param.schema.get_files_template_representation( + param.serialized_name: param.schema.get_files_and_data_template_representation( optional=not param.required, description=param.description, ) @@ -69,12 +70,24 @@ def _get_files_example_template(builder: BuilderType) -> List[str]: retval = [ "# multipart input template you can fill out and use as your `files` input.", ] - retval.extend(f"files = {_serialize_files_dict(multipart_params)}".splitlines()) + retval.extend(f"files = {_serialize_files_or_data_dict(multipart_params)}".splitlines()) return retval raise ValueError( "You're trying to get a template for your multipart params, but you don't have multipart params" ) +def _get_data_example_template(builder: BuilderType) -> List[str]: + data_inputs = builder.parameters.data_inputs + if data_inputs: + retval = [ + "# form-encoded input template you can fill out and use as your `data` input." + ] + retval.extend(f"data = {_serialize_files_or_data_dict(data_inputs)}".splitlines()) + return retval + raise ValueError( + "You're trying to get a template for your form-encoded params, but you don't have form-encoded params" + ) + def _content_type_error_check(builder: BuilderType) -> List[str]: retval = ["else:"] retval.append(" raise ValueError(") @@ -83,14 +96,16 @@ def _content_type_error_check(builder: BuilderType) -> List[str]: retval.append(" )") return retval -def _serialize_files_body(builder: BuilderType) -> List[str]: +def _serialize_files_and_data_body(builder: BuilderType, param_name: str) -> List[str]: retval: List[str] = [] + # we have to construct our form data before passing to the request as well + retval.append("# Construct form data") for constant in builder.parameters.constant: - if constant.is_multipart: + if constant.is_multipart or constant.is_data_input: retval.append(_declare_constant(constant)) - retval.append("files = {") - for parameter in builder.parameters.body: - retval.append(f' "{parameter.rest_api_name}": {parameter.serialized_name},') + retval.append(f"{param_name} = {{") + for param in builder.parameters.body: + retval.append(f' "{param.rest_api_name}": {param.serialized_name},') retval.append("}") return retval @@ -236,6 +251,9 @@ def _has_json_example_template(self, builder: BuilderType) -> bool: @abstractmethod def _has_files_example_template(self, builder: BuilderType) -> bool: ... + @abstractmethod + def _has_data_example_template(self, builder: BuilderType) -> bool: + ... @abstractmethod def _json_example_param_name(self, builder: BuilderType) -> str: @@ -294,14 +312,14 @@ def description_and_summary(self, builder: BuilderType) -> List[str]: def param_description(self, builder: Union[RequestBuilder, Operation]) -> List[str]: # pylint: disable=no-self-use description_list: List[str] = [] - for parameter in [m for m in builder.parameters.method if not m.is_hidden]: + for param in [m for m in builder.parameters.method if not m.is_hidden]: description_list.extend( - f":{parameter.description_keyword} { parameter.serialized_name }: { parameter.description }".replace( + f":{param.description_keyword} { param.serialized_name }: { param.description }".replace( "\n", "\n " ).split("\n") ) description_list.append( - f":{parameter.docstring_type_keyword} { parameter.serialized_name }: { parameter.docstring_type }" + f":{param.docstring_type_keyword} { param.serialized_name }: { param.docstring_type }" ) try: request_builder: RequestBuilder = cast(Operation, builder).request_builder @@ -344,6 +362,9 @@ def get_example_template(self, builder: BuilderType) -> List[str]: if self._has_files_example_template(builder): template.append("") template += _get_files_example_template(builder) + if self._has_data_example_template(builder): + template.append("") + template += _get_data_example_template(builder) if self._get_json_response_template_to_status_codes(builder): template.append("") template += self._get_json_response_template(builder) @@ -396,18 +417,18 @@ def serializer_name(self) -> str: ... def _serialize_parameter( - self, parameter: Parameter, function_name: str + self, param: Parameter, function_name: str ) -> List[str]: set_parameter = "{}_parameters['{}'] = {}".format( function_name, - parameter.rest_api_name, - utils.build_serialize_data_call(parameter, function_name, self.serializer_name) + param.rest_api_name, + utils.build_serialize_data_call(param, function_name, self.serializer_name) ) - if parameter.required: + if param.required: retval = [set_parameter] else: retval = [ - f"if {parameter.full_serialized_name} is not None:", + f"if {param.full_serialized_name} is not None:", f" {set_parameter}" ] return retval @@ -453,7 +474,7 @@ def want_example_template(self, builder: BuilderType) -> bool: return False # if we're not exposing rest layer, don't need to generate if builder.parameters.has_body: body_kwargs = set(builder.parameters.body_kwarg_names.keys()) - return bool(body_kwargs.intersection({"json", "files"})) + return bool(body_kwargs.intersection({"json", "files", "data"})) return bool(self._get_json_response_template_to_status_codes(builder)) @property @@ -485,6 +506,9 @@ def _has_json_example_template(self, builder: BuilderType) -> bool: def _has_files_example_template(self, builder: BuilderType) -> bool: return "files" in builder.parameters.body_kwarg_names + def _has_data_example_template(self, builder: BuilderType) -> bool: + return "data" in builder.parameters.body_kwarg_names + @abstractmethod def _body_params_to_pass_to_request_creation(self, builder: BuilderType) -> List[str]: ... @@ -661,7 +685,7 @@ def want_example_template(self, builder: BuilderType) -> bool: if self.code_model.options['models_mode']: return False if builder.parameters.has_body: - if builder.parameters.body[0].is_multipart: + if builder.parameters.multipart or builder.parameters.data_inputs: return True body_params = builder.parameters.body return any([b for b in body_params if isinstance(b.schema, (DictionarySchema, ListSchema, ObjectSchema))]) @@ -671,11 +695,17 @@ def _json_example_param_name(self, builder: BuilderType) -> str: return builder.parameters.body[0].serialized_name def _has_json_example_template(self, builder: BuilderType) -> bool: - return builder.parameters.has_body and not builder.parameters.body[0].is_multipart + return ( + builder.parameters.has_body and + not (builder.parameters.multipart or builder.parameters.data_inputs) + ) def _has_files_example_template(self, builder: BuilderType) -> bool: return bool(builder.parameters.multipart) + def _has_data_example_template(self, builder: BuilderType) -> bool: + return bool(builder.parameters.data_inputs) + def _serialize_body_call( self, builder: BuilderType, send_xml: bool, ser_ctxt: Optional[str], ser_ctxt_name: str ) -> str: @@ -756,16 +786,17 @@ def _call_request_builder_helper( if builder.parameters.grouped: # request builders don't allow grouped parameters, so we group them before making the call retval.extend(_serialize_grouped_body(builder)) - if request_builder.multipart: - # we have to construct our form data before passing to the request as well - retval.append("# Construct form data") - if not self.code_model.options["version_tolerant"]: - retval.extend(_serialize_files_body(builder)) + if builder.parameters.is_flattened: # unflatten before passing to request builder as well retval.extend(_serialize_flattened_body(builder)) - if builder.parameters.has_body and not builder.parameters.body[0].constant: + if request_builder.multipart or request_builder.parameters.data_inputs: + param_name = "files" if request_builder.multipart else "data" + if not self.code_model.options["version_tolerant"]: + retval.extend(_serialize_files_and_data_body(builder, param_name)) + elif builder.parameters.has_body and not builder.parameters.body[0].constant: retval.extend(self._serialize_body_parameters(builder)) + if self.code_model.options["builders_visibility"] == "embedded": request_path_name = request_builder.name else: diff --git a/package.json b/package.json index af449a69f58..b34d9726eec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "5.9.2", + "version": "5.9.3", "description": "The Python extension for generators in AutoRest.", "scripts": { "prepare": "node run-python3.js prepare.py", diff --git a/tasks.py b/tasks.py index 745951128c4..5110a905403 100644 --- a/tasks.py +++ b/tasks.py @@ -49,6 +49,7 @@ class _SwaggerGroup(Enum): 'BodyFile': 'body-file.json', 'Constants': 'constants.json', 'BodyFormData': 'body-formdata.json', + 'BodyFormUrlEncodedData': 'body-formdata-urlencoded.json', 'BodyInteger': 'body-integer.json', 'BodyNumber': 'body-number.json', 'BodyString': 'body-string.json', diff --git a/test/vanilla/legacy/AcceptanceTests/asynctests/test_urlencoded.py b/test/vanilla/legacy/AcceptanceTests/asynctests/test_urlencoded.py new file mode 100644 index 00000000000..046ef770f10 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/asynctests/test_urlencoded.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddata.aio import BodyFormsDataURLEncoded +from bodyformurlencodeddata.models import PetFood, PetType + +@pytest.fixture +async def client(): + async with BodyFormsDataURLEncoded() as client: + yield client + +@pytest.mark.asyncio +async def test_update_pet_with_form(client): + await client.formdataurlencoded.update_pet_with_form( + pet_id=1, + pet_type=PetType.DOG, + pet_food=PetFood.MEAT, + pet_age=42, + name="Fido", + ) diff --git a/test/vanilla/legacy/AcceptanceTests/test_urlencoded.py b/test/vanilla/legacy/AcceptanceTests/test_urlencoded.py new file mode 100644 index 00000000000..008883b1550 --- /dev/null +++ b/test/vanilla/legacy/AcceptanceTests/test_urlencoded.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddata import BodyFormsDataURLEncoded +from bodyformurlencodeddata.models import PetFood, PetType + +@pytest.fixture +def client(): + with BodyFormsDataURLEncoded() as client: + yield client + +def test_update_pet_with_form(client): + client.formdataurlencoded.update_pet_with_form( + pet_id=1, + pet_type=PetType.DOG, + pet_food=PetFood.MEAT, + pet_age=42, + name="Fido", + ) diff --git a/test/vanilla/legacy/AcceptanceTests/test_zzz.py b/test/vanilla/legacy/AcceptanceTests/test_zzz.py index 461c6aa86c8..5d4db919e0d 100644 --- a/test/vanilla/legacy/AcceptanceTests/test_zzz.py +++ b/test/vanilla/legacy/AcceptanceTests/test_zzz.py @@ -59,7 +59,6 @@ def test_ensure_coverage(self): 'putDateTimeMaxUtc7MS': 1, # Python doesn't support 7 digits ms datetime 'FormdataStreamUploadFile': 1, # Form data not supported yet 'StreamUploadFile': 1, # Form data not supported yet - "UpdatePetWithForm": 1, # autorest core change needed to do this hasn't been merged yet } for name in optional_report: if "Options" in name: @@ -67,6 +66,9 @@ def test_ensure_coverage(self): if "Multiapi" in name: # multiapi is in a separate test folder missing_features_or_bugs[name] = 1 + if "LLC" in name: + # llc is in a separate test folder + missing_features_or_bugs[name] = 1 print("Optional coverage:") self._print_report(optional_report, not_supported, missing_features_or_bugs) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py index 4acbd5621a4..5f6254edf02 100644 --- a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/aio/operations/_formdata_operations.py @@ -74,8 +74,6 @@ async def upload_file(self, file_content: IO, file_name: str, **kwargs: Any) -> content_type = kwargs.pop("content_type", None) # type: Optional[str] - files = None - data = None # Construct form data files = { "fileContent": file_content, @@ -85,7 +83,6 @@ async def upload_file(self, file_content: IO, file_name: str, **kwargs: Any) -> request = build_upload_file_request( content_type=content_type, files=files, - data=data, template_url=self.upload_file.metadata["url"], ) request = _convert_request(request, files) @@ -169,8 +166,6 @@ async def upload_files(self, file_content: List[IO], **kwargs: Any) -> IO: content_type = kwargs.pop("content_type", None) # type: Optional[str] - files = None - data = None # Construct form data files = { "fileContent": file_content, @@ -179,7 +174,6 @@ async def upload_files(self, file_content: List[IO], **kwargs: Any) -> IO: request = build_upload_files_request( content_type=content_type, files=files, - data=data, template_url=self.upload_files.metadata["url"], ) request = _convert_request(request, files) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py index e56d8a702ff..d32bc99b1cb 100644 --- a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/operations/_formdata_operations.py @@ -154,8 +154,6 @@ def upload_file( content_type = kwargs.pop("content_type", None) # type: Optional[str] - files = None - data = None # Construct form data files = { "fileContent": file_content, @@ -165,7 +163,6 @@ def upload_file( request = build_upload_file_request( content_type=content_type, files=files, - data=data, template_url=self.upload_file.metadata["url"], ) request = _convert_request(request, files) @@ -259,8 +256,6 @@ def upload_files( content_type = kwargs.pop("content_type", None) # type: Optional[str] - files = None - data = None # Construct form data files = { "fileContent": file_content, @@ -269,7 +264,6 @@ def upload_files( request = build_upload_files_request( content_type=content_type, files=files, - data=data, template_url=self.upload_files.metadata["url"], ) request = _convert_request(request, files) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/__init__.py new file mode 100644 index 00000000000..c4c48268a9b --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded +from ._version import VERSION + +__version__ = VERSION +__all__ = ["BodyFormsDataURLEncoded"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_body_forms_data_url_encoded.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..eb2056242b7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_body_forms_data_url_encoded.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import BodyFormsDataURLEncodedConfiguration +from .operations import FormdataurlencodedOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class BodyFormsDataURLEncoded(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdataurlencoded: FormdataurlencodedOperations operations + :vartype formdataurlencoded: bodyformurlencodeddata.operations.FormdataurlencodedOperations + :param base_url: Service URL. Default value is 'http://localhost:3000'. + :type base_url: str + """ + + def __init__( + self, + base_url="http://localhost:3000", # type: str + **kwargs # type: Any + ): + # type: (...) -> None + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.formdataurlencoded = FormdataurlencodedOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> BodyFormsDataURLEncoded + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_configuration.py new file mode 100644 index 00000000000..1630989c8c5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_configuration.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py new file mode 100644 index 00000000000..9aad73fc743 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_version.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/__init__.py new file mode 100644 index 00000000000..d29143c0791 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/__init__.py @@ -0,0 +1,11 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded + +__all__ = ["BodyFormsDataURLEncoded"] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_body_forms_data_url_encoded.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..5a946a8e3cc --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_body_forms_data_url_encoded.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import BodyFormsDataURLEncodedConfiguration +from .operations import FormdataurlencodedOperations + + +class BodyFormsDataURLEncoded: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdataurlencoded: FormdataurlencodedOperations operations + :vartype formdataurlencoded: bodyformurlencodeddata.aio.operations.FormdataurlencodedOperations + :param base_url: Service URL. Default value is 'http://localhost:3000'. + :type base_url: str + """ + + def __init__(self, base_url: str = "http://localhost:3000", **kwargs: Any) -> None: + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.formdataurlencoded = FormdataurlencodedOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "BodyFormsDataURLEncoded": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_configuration.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_configuration.py new file mode 100644 index 00000000000..71cd7fc41ca --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/__init__.py new file mode 100644 index 00000000000..1f1a35610b1 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._formdataurlencoded_operations import FormdataurlencodedOperations + +__all__ = [ + "FormdataurlencodedOperations", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py new file mode 100644 index 00000000000..3d832b5f446 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/aio/operations/_formdataurlencoded_operations.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._formdataurlencoded_operations import build_update_pet_with_form_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FormdataurlencodedOperations: + """FormdataurlencodedOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~bodyformurlencodeddata.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def update_pet_with_form( + self, + pet_id: int, + pet_type: Union[str, "_models.PetType"], + pet_food: Union[str, "_models.PetFood"], + pet_age: int, + name: Optional[str] = None, + status: Optional[str] = None, + **kwargs: Any + ) -> None: + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :param pet_type: Can take a value of dog, or cat, or fish. + :type pet_type: str or ~bodyformurlencodeddata.models.PetType + :param pet_food: Can take a value of meat, or fish, or plant. + :type pet_food: str or ~bodyformurlencodeddata.models.PetFood + :param pet_age: How many years is it old?. + :type pet_age: int + :param name: Updated name of the pet. + :type name: str + :param status: Updated status of the pet. + :type status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + content_type = kwargs.pop("content_type", "application/x-www-form-urlencoded") # type: Optional[str] + + # Construct form data + data = { + "pet_type": pet_type, + "pet_food": pet_food, + "pet_age": pet_age, + "name": name, + "status": status, + } + + request = build_update_pet_with_form_request( + pet_id=pet_id, + content_type=content_type, + data=data, + template_url=self.update_pet_with_form.metadata["url"], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 405]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update_pet_with_form.metadata = {"url": "/formsdataurlencoded/pet/add/{petId}"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/__init__.py new file mode 100644 index 00000000000..6a6c3a0437f --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ( + Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema, + ) +except (SyntaxError, ImportError): + from ._models import Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema # type: ignore + +from ._body_forms_data_url_encoded_enums import ( + PetFood, + PetType, +) + +__all__ = [ + "Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema", + "PetFood", + "PetType", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_body_forms_data_url_encoded_enums.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_body_forms_data_url_encoded_enums.py new file mode 100644 index 00000000000..86d0f7d40d7 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_body_forms_data_url_encoded_enums.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class PetFood(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Can take a value of meat, or fish, or plant""" + + MEAT = "meat" + FISH = "fish" + PLANT = "plant" + + +class PetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Can take a value of dog, or cat, or fish""" + + DOG = "dog" + CAT = "cat" + FISH = "fish" diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models.py new file mode 100644 index 00000000000..91006af9a52 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema( + msrest.serialization.Model +): + """Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema. + + All required parameters must be populated in order to send to Azure. + + :ivar pet_type: Required. Can take a value of dog, or cat, or fish. Possible values include: + "dog", "cat", "fish". + :vartype pet_type: str or ~bodyformurlencodeddata.models.PetType + :ivar pet_food: Required. Can take a value of meat, or fish, or plant. Possible values include: + "meat", "fish", "plant". + :vartype pet_food: str or ~bodyformurlencodeddata.models.PetFood + :ivar pet_age: Required. How many years is it old?. + :vartype pet_age: int + :ivar name: Updated name of the pet. + :vartype name: str + :ivar status: Updated status of the pet. + :vartype status: str + """ + + _validation = { + "pet_type": {"required": True}, + "pet_food": {"required": True}, + "pet_age": {"required": True}, + } + + _attribute_map = { + "pet_type": {"key": "pet_type", "type": "str"}, + "pet_food": {"key": "pet_food", "type": "str"}, + "pet_age": {"key": "pet_age", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ + :keyword pet_type: Required. Can take a value of dog, or cat, or fish. Possible values include: + "dog", "cat", "fish". + :paramtype pet_type: str or ~bodyformurlencodeddata.models.PetType + :keyword pet_food: Required. Can take a value of meat, or fish, or plant. Possible values + include: "meat", "fish", "plant". + :paramtype pet_food: str or ~bodyformurlencodeddata.models.PetFood + :keyword pet_age: Required. How many years is it old?. + :paramtype pet_age: int + :keyword name: Updated name of the pet. + :paramtype name: str + :keyword status: Updated status of the pet. + :paramtype status: str + """ + super( + Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema, self + ).__init__(**kwargs) + self.pet_type = kwargs["pet_type"] + self.pet_food = kwargs["pet_food"] + self.pet_age = kwargs["pet_age"] + self.name = kwargs.get("name", None) + self.status = kwargs.get("status", None) diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models_py3.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models_py3.py new file mode 100644 index 00000000000..b1a76f2bc76 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/models/_models_py3.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Optional, Union + +import msrest.serialization + +from ._body_forms_data_url_encoded_enums import * + + +class Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema( + msrest.serialization.Model +): + """Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema. + + All required parameters must be populated in order to send to Azure. + + :ivar pet_type: Required. Can take a value of dog, or cat, or fish. Possible values include: + "dog", "cat", "fish". + :vartype pet_type: str or ~bodyformurlencodeddata.models.PetType + :ivar pet_food: Required. Can take a value of meat, or fish, or plant. Possible values include: + "meat", "fish", "plant". + :vartype pet_food: str or ~bodyformurlencodeddata.models.PetFood + :ivar pet_age: Required. How many years is it old?. + :vartype pet_age: int + :ivar name: Updated name of the pet. + :vartype name: str + :ivar status: Updated status of the pet. + :vartype status: str + """ + + _validation = { + "pet_type": {"required": True}, + "pet_food": {"required": True}, + "pet_age": {"required": True}, + } + + _attribute_map = { + "pet_type": {"key": "pet_type", "type": "str"}, + "pet_food": {"key": "pet_food", "type": "str"}, + "pet_age": {"key": "pet_age", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + pet_type: Union[str, "PetType"], + pet_food: Union[str, "PetFood"], + pet_age: int, + name: Optional[str] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword pet_type: Required. Can take a value of dog, or cat, or fish. Possible values include: + "dog", "cat", "fish". + :paramtype pet_type: str or ~bodyformurlencodeddata.models.PetType + :keyword pet_food: Required. Can take a value of meat, or fish, or plant. Possible values + include: "meat", "fish", "plant". + :paramtype pet_food: str or ~bodyformurlencodeddata.models.PetFood + :keyword pet_age: Required. How many years is it old?. + :paramtype pet_age: int + :keyword name: Updated name of the pet. + :paramtype name: str + :keyword status: Updated status of the pet. + :paramtype status: str + """ + super( + Paths14Hl8BdFormsdataurlencodedPetAddPetidPostRequestbodyContentApplicationXWwwFormUrlencodedSchema, self + ).__init__(**kwargs) + self.pet_type = pet_type + self.pet_food = pet_food + self.pet_age = pet_age + self.name = name + self.status = status diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/__init__.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/__init__.py new file mode 100644 index 00000000000..1f1a35610b1 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._formdataurlencoded_operations import FormdataurlencodedOperations + +__all__ = [ + "FormdataurlencodedOperations", +] diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py new file mode 100644 index 00000000000..915c7a851a2 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/operations/_formdataurlencoded_operations.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_update_pet_with_form_request( + pet_id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/formsdataurlencoded/pet/add/{petId}') + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, 'int'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class FormdataurlencodedOperations(object): + """FormdataurlencodedOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~bodyformurlencodeddata.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def update_pet_with_form( + self, + pet_id, # type: int + pet_type, # type: Union[str, "_models.PetType"] + pet_food, # type: Union[str, "_models.PetFood"] + pet_age, # type: int + name=None, # type: Optional[str] + status=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :param pet_type: Can take a value of dog, or cat, or fish. + :type pet_type: str or ~bodyformurlencodeddata.models.PetType + :param pet_food: Can take a value of meat, or fish, or plant. + :type pet_food: str or ~bodyformurlencodeddata.models.PetFood + :param pet_age: How many years is it old?. + :type pet_age: int + :param name: Updated name of the pet. + :type name: str + :param status: Updated status of the pet. + :type status: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + content_type = kwargs.pop("content_type", "application/x-www-form-urlencoded") # type: Optional[str] + + # Construct form data + data = { + "pet_type": pet_type, + "pet_food": pet_food, + "pet_age": pet_age, + "name": name, + "status": status, + } + + request = build_update_pet_with_form_request( + pet_id=pet_id, + content_type=content_type, + data=data, + template_url=self.update_pet_with_form.metadata["url"], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 405]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update_pet_with_form.metadata = {"url": "/formsdataurlencoded/pet/add/{petId}"} # type: ignore diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/py.typed b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/setup.py b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/setup.py new file mode 100644 index 00000000000..25974680ef5 --- /dev/null +++ b/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/setup.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "bodyformsdataurlencoded" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.19.0"] + +setup( + name=NAME, + version=VERSION, + description="BodyFormsDataURLEncoded", + author_email="", + url="", + keywords=["Swagger", "BodyFormsDataURLEncoded"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/legacy/requirements.txt b/test/vanilla/legacy/requirements.txt index 781d6a28671..64e0057ef99 100644 --- a/test/vanilla/legacy/requirements.txt +++ b/test/vanilla/legacy/requirements.txt @@ -21,6 +21,7 @@ azure-core==1.19.0 -e ./Expected/AcceptanceTests/BodyDuration -e ./Expected/AcceptanceTests/BodyFile -e ./Expected/AcceptanceTests/BodyFormData +-e ./Expected/AcceptanceTests/BodyFormUrlEncodedData -e ./Expected/AcceptanceTests/BodyInteger -e ./Expected/AcceptanceTests/BodyNumber -e ./Expected/AcceptanceTests/BodyString diff --git a/test/vanilla/low-level/AcceptanceTests/asynctests/test_urlencoded.py b/test/vanilla/low-level/AcceptanceTests/asynctests/test_urlencoded.py new file mode 100644 index 00000000000..801203ccc91 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/asynctests/test_urlencoded.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddatalowlevel.aio import BodyFormsDataURLEncoded +from bodyformurlencodeddatalowlevel.rest import formdataurlencoded + +@pytest.fixture +async def client(): + async with BodyFormsDataURLEncoded() as client: + yield client + +@pytest.fixture +def send_request(client, base_send_request): + async def _send_request(request): + return await base_send_request(client, request) + return _send_request + +@pytest.mark.asyncio +async def test_update_pet_with_form(send_request): + request = formdataurlencoded.build_update_pet_with_form_request( + pet_id=1, + data={ + "pet_type": "dog", + "pet_food": "meat", + "pet_age": 42, + "name": "Fido", + } + ) + await send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_urlencoded.py b/test/vanilla/low-level/AcceptanceTests/test_urlencoded.py new file mode 100644 index 00000000000..a88f785c3c8 --- /dev/null +++ b/test/vanilla/low-level/AcceptanceTests/test_urlencoded.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddatalowlevel import BodyFormsDataURLEncoded +from bodyformurlencodeddatalowlevel.rest import formdataurlencoded + +@pytest.fixture +def client(): + with BodyFormsDataURLEncoded() as client: + yield client + +@pytest.fixture +def send_request(client, base_send_request): + def _send_request(request): + return base_send_request(client, request) + return _send_request + +def test_update_pet_with_form(send_request): + request = formdataurlencoded.build_update_pet_with_form_request( + pet_id=1, + data={ + "pet_type": "dog", + "pet_food": "meat", + "pet_age": 42, + "name": "Fido", + } + ) + send_request(request) diff --git a/test/vanilla/low-level/AcceptanceTests/test_zzz.py b/test/vanilla/low-level/AcceptanceTests/test_zzz.py index b7e2096d4d9..cc90dceb160 100644 --- a/test/vanilla/low-level/AcceptanceTests/test_zzz.py +++ b/test/vanilla/low-level/AcceptanceTests/test_zzz.py @@ -75,7 +75,6 @@ def test_ensure_coverage(self): 'putDateTimeMaxUtc7MS': 1, # Python doesn't support 7 digits ms datetime 'FormdataStreamUploadFile': 1, # Form data not supported yet 'StreamUploadFile': 1, # Form data not supported yet - "UpdatePetWithForm": 1, # autorest core change needed to do this hasn't been merged yet "sendErrorWithParamNameModels": 1, "putDecimalBigNegativeDecimal": 1, "verifyHost": 1, @@ -86,6 +85,9 @@ def test_ensure_coverage(self): if "Multiapi" in name: # multiapi is in a separate test folder missing_features_or_bugs[name] = 1 + if "LLC" in name: + # llc is in a separate test folder + missing_features_or_bugs[name] = 1 print("Optional coverage:") self._print_report(optional_report, not_supported, missing_features_or_bugs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_auto_rest_swagger_bat_form_data_service.py index 0b0efaa218a..986f664fb8a 100644 --- a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_auto_rest_swagger_bat_form_data_service.py +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/_auto_rest_swagger_bat_form_data_service.py @@ -53,7 +53,7 @@ def send_request( Use these helper methods to create the request you pass to this method. >>> from bodyformdatalowlevel.rest import formdata - >>> request = formdata.build_upload_file_request(files=files, data=data, content=content, **kwargs) + >>> request = formdata.build_upload_file_request(files=files, content=content, **kwargs) >>> response = client.send_request(request) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_auto_rest_swagger_bat_form_data_service.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_auto_rest_swagger_bat_form_data_service.py index 63ac1a66c5f..a27548ee656 100644 --- a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_auto_rest_swagger_bat_form_data_service.py +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/aio/_auto_rest_swagger_bat_form_data_service.py @@ -42,7 +42,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHt Use these helper methods to create the request you pass to this method. >>> from bodyformdatalowlevel.rest import formdata - >>> request = formdata.build_upload_file_request(files=files, data=data, content=content, **kwargs) + >>> request = formdata.build_upload_file_request(files=files, content=content, **kwargs) >>> response = await client.send_request(request) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders.py index 7a3be224636..8885305e4e4 100644 --- a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders.py +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders.py @@ -30,9 +30,6 @@ def build_upload_file_request( :keyword files: Multipart input for files. See the template in our example to find the input shape. File to upload. :paramtype files: dict[str, any] - :keyword data: Pass in dictionary that contains form data to include in the body of the - request. File to upload. - :paramtype data: dict[str, any] :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). File to upload. :paramtype content: any @@ -46,15 +43,8 @@ def build_upload_file_request( # multipart input template you can fill out and use as your `files` input. files = { - content: {}, # Optional. Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). File to upload. - data: { - "str": {} # Optional. Pass in dictionary that contains form data to include in the body of the request. File to upload. - }, file_content: b'bytes', # File to upload. - file_name: "str", # File name to upload. Name has to be spelled exactly as written here. - files: { - "str": {} # Optional. Multipart input for files. See the template in our example to find the input shape. File to upload. - } + file_name: "str" # File name to upload. Name has to be spelled exactly as written here. } """ @@ -128,9 +118,6 @@ def build_upload_files_request( :keyword files: Multipart input for files. See the template in our example to find the input shape. Files to upload. :paramtype files: dict[str, any] - :keyword data: Pass in dictionary that contains form data to include in the body of the - request. Files to upload. - :paramtype data: dict[str, any] :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Files to upload. :paramtype content: any @@ -144,16 +131,9 @@ def build_upload_files_request( # multipart input template you can fill out and use as your `files` input. files = { - content: {}, # Optional. Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Files to upload. - data: { - "str": {} # Optional. Pass in dictionary that contains form data to include in the body of the request. Files to upload. - }, file_content: [ b'bytes' # Files to upload. - ], - files: { - "str": {} # Optional. Multipart input for files. See the template in our example to find the input shape. Files to upload. - } + ] } """ diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders_py3.py index f2c3cacd5ef..2403ccbb9a4 100644 --- a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders_py3.py +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormDataLowLevel/bodyformdatalowlevel/rest/formdata/_request_builders_py3.py @@ -14,7 +14,7 @@ def build_upload_file_request( - *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any + *, files: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: """Upload file. @@ -24,9 +24,6 @@ def build_upload_file_request( :keyword files: Multipart input for files. See the template in our example to find the input shape. File to upload. :paramtype files: dict[str, any] - :keyword data: Pass in dictionary that contains form data to include in the body of the - request. File to upload. - :paramtype data: dict[str, any] :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). File to upload. :paramtype content: any @@ -40,15 +37,8 @@ def build_upload_file_request( # multipart input template you can fill out and use as your `files` input. files = { - content: {}, # Optional. Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). File to upload. - data: { - "str": {} # Optional. Pass in dictionary that contains form data to include in the body of the request. File to upload. - }, file_content: b'bytes', # File to upload. - file_name: "str", # File name to upload. Name has to be spelled exactly as written here. - files: { - "str": {} # Optional. Multipart input for files. See the template in our example to find the input shape. File to upload. - } + file_name: "str" # File name to upload. Name has to be spelled exactly as written here. } """ @@ -64,9 +54,7 @@ def build_upload_file_request( header_parameters["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs - ) + return HttpRequest(method="POST", url=url, headers=header_parameters, files=files, content=content, **kwargs) def build_upload_file_via_body_request(*, content: Any, **kwargs: Any) -> HttpRequest: @@ -100,7 +88,7 @@ def build_upload_file_via_body_request(*, content: Any, **kwargs: Any) -> HttpRe def build_upload_files_request( - *, files: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any + *, files: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: """Upload multiple files. @@ -110,9 +98,6 @@ def build_upload_files_request( :keyword files: Multipart input for files. See the template in our example to find the input shape. Files to upload. :paramtype files: dict[str, any] - :keyword data: Pass in dictionary that contains form data to include in the body of the - request. Files to upload. - :paramtype data: dict[str, any] :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Files to upload. :paramtype content: any @@ -126,16 +111,9 @@ def build_upload_files_request( # multipart input template you can fill out and use as your `files` input. files = { - content: {}, # Optional. Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Files to upload. - data: { - "str": {} # Optional. Pass in dictionary that contains form data to include in the body of the request. Files to upload. - }, file_content: [ b'bytes' # Files to upload. - ], - files: { - "str": {} # Optional. Multipart input for files. See the template in our example to find the input shape. Files to upload. - } + ] } """ @@ -151,6 +129,4 @@ def build_upload_files_request( header_parameters["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") header_parameters["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", url=url, headers=header_parameters, files=files, data=data, content=content, **kwargs - ) + return HttpRequest(method="POST", url=url, headers=header_parameters, files=files, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/__init__.py new file mode 100644 index 00000000000..c4c48268a9b --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded +from ._version import VERSION + +__version__ = VERSION +__all__ = ["BodyFormsDataURLEncoded"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_body_forms_data_url_encoded.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..8fd50df8b32 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_body_forms_data_url_encoded.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import BodyFormsDataURLEncodedConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class BodyFormsDataURLEncoded(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :keyword endpoint: Service URL. Default value is 'http://localhost:3000'. + :paramtype endpoint: str + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + endpoint = kwargs.pop("endpoint", "http://localhost:3000") # type: str + + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = PipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse + """Runs the network request through the client's chained policies. + + We have helper methods to create requests specific to this service in `bodyformurlencodeddatalowlevel.rest`. + Use these helper methods to create the request you pass to this method. + + >>> from bodyformurlencodeddatalowlevel.rest import formdataurlencoded + >>> request = formdataurlencoded.build_update_pet_with_form_request(pet_id, data=data, content=content, **kwargs) + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> BodyFormsDataURLEncoded + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_configuration.py new file mode 100644 index 00000000000..1630989c8c5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_configuration.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_vendor.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_vendor.py new file mode 100644 index 00000000000..54f238858ed --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_vendor.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_version.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/__init__.py new file mode 100644 index 00000000000..d29143c0791 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/__init__.py @@ -0,0 +1,11 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded + +__all__ = ["BodyFormsDataURLEncoded"] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_body_forms_data_url_encoded.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..14dbc3ed63c --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_body_forms_data_url_encoded.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import BodyFormsDataURLEncodedConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class BodyFormsDataURLEncoded: + """Test Infrastructure for AutoRest Swagger BAT. + + :keyword endpoint: Service URL. Default value is 'http://localhost:3000'. + :paramtype endpoint: str + """ + + def __init__(self, *, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + We have helper methods to create requests specific to this service in `bodyformurlencodeddatalowlevel.rest`. + Use these helper methods to create the request you pass to this method. + + >>> from bodyformurlencodeddatalowlevel.rest import formdataurlencoded + >>> request = formdataurlencoded.build_update_pet_with_form_request(pet_id, data=data, content=content, **kwargs) + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "BodyFormsDataURLEncoded": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_configuration.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_configuration.py new file mode 100644 index 00000000000..71cd7fc41ca --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/py.typed b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/__init__.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/__init__.py new file mode 100644 index 00000000000..19262e50205 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._request_builders_py3 import build_update_pet_with_form_request +except (SyntaxError, ImportError): + from ._request_builders import build_update_pet_with_form_request # type: ignore + +__all__ = [ + "build_update_pet_with_form_request", +] diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders.py new file mode 100644 index 00000000000..e0b72ec8cde --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING + +from azure.core.rest import HttpRequest +from msrest import Serializer + +from ..._vendor import _format_url_section + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + +_SERIALIZER = Serializer() + +# fmt: off + +def build_update_pet_with_form_request( + pet_id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :keyword data: Pass in dictionary that contains form data to include in the body of the + request. Can take a value of dog, or cat, or fish. + :paramtype data: dict[str, any] + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Can take a value of dog, or cat, or fish. + :paramtype content: any + :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's + `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to + incorporate this response into your code flow. + :rtype: ~azure.core.rest.HttpRequest + + Example: + .. code-block:: python + + # form-encoded input template you can fill out and use as your `data` input. + data = { + name: "str", # Optional. Updated name of the pet. + pet_age: 0, # How many years is it old?. + pet_food: "str", # Can take a value of meat, or fish, or plant. Possible values are: "meat", "fish", and "plant". + pet_type: "str", # Can take a value of dog, or cat, or fish. Possible values are: "dog", "cat", and "fish". + status: "str" # Optional. Updated status of the pet. + } + """ + + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/formsdataurlencoded/pet/add/{petId}') + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, 'int'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders_py3.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders_py3.py new file mode 100644 index 00000000000..467c02eb130 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/bodyformurlencodeddatalowlevel/rest/formdataurlencoded/_request_builders_py3.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Dict, Optional + +from azure.core.rest import HttpRequest +from msrest import Serializer + +from ..._vendor import _format_url_section + +_SERIALIZER = Serializer() + + +def build_update_pet_with_form_request( + pet_id: int, *, data: Optional[Dict[str, Any]] = None, content: Any = None, **kwargs: Any +) -> HttpRequest: + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder + into your code flow. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :keyword data: Pass in dictionary that contains form data to include in the body of the + request. Can take a value of dog, or cat, or fish. + :paramtype data: dict[str, any] + :keyword content: Pass in binary content you want in the body of the request (typically bytes, + a byte iterator, or stream input). Can take a value of dog, or cat, or fish. + :paramtype content: any + :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's + `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to + incorporate this response into your code flow. + :rtype: ~azure.core.rest.HttpRequest + + Example: + .. code-block:: python + + # form-encoded input template you can fill out and use as your `data` input. + data = { + name: "str", # Optional. Updated name of the pet. + pet_age: 0, # How many years is it old?. + pet_food: "str", # Can take a value of meat, or fish, or plant. Possible values are: "meat", "fish", and "plant". + pet_type: "str", # Can take a value of dog, or cat, or fish. Possible values are: "dog", "cat", and "fish". + status: "str" # Optional. Updated status of the pet. + } + """ + + content_type = kwargs.pop("content_type", None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", "/formsdataurlencoded/pet/add/{petId}") + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, "int"), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=url, headers=header_parameters, data=data, content=content, **kwargs) diff --git a/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/setup.py b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/setup.py new file mode 100644 index 00000000000..25974680ef5 --- /dev/null +++ b/test/vanilla/low-level/Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel/setup.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "bodyformsdataurlencoded" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.19.0"] + +setup( + name=NAME, + version=VERSION, + description="BodyFormsDataURLEncoded", + author_email="", + url="", + keywords=["Swagger", "BodyFormsDataURLEncoded"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/low-level/coverage/report-optional.json b/test/vanilla/low-level/coverage/report-optional.json index fbac9e8dead..9cec89ff359 100644 --- a/test/vanilla/low-level/coverage/report-optional.json +++ b/test/vanilla/low-level/coverage/report-optional.json @@ -1,6 +1,6 @@ { "StreamUploadFile": 10, - "UpdatePetWithForm": 0, + "UpdatePetWithForm": 2, "getDecimalInvalid": 2, "getDecimalBig": 2, "getDecimalSmall": 2, diff --git a/test/vanilla/low-level/requirements.txt b/test/vanilla/low-level/requirements.txt index 209417623b5..fc35430f74f 100644 --- a/test/vanilla/low-level/requirements.txt +++ b/test/vanilla/low-level/requirements.txt @@ -20,6 +20,7 @@ azure-core==1.19.0 -e ./Expected/AcceptanceTests/BodyDurationLowLevel -e ./Expected/AcceptanceTests/BodyFileLowLevel -e ./Expected/AcceptanceTests/BodyFormDataLowLevel +-e ./Expected/AcceptanceTests/BodyFormUrlEncodedDataLowLevel -e ./Expected/AcceptanceTests/BodyIntegerLowLevel -e ./Expected/AcceptanceTests/BodyNumberLowLevel -e ./Expected/AcceptanceTests/BodyStringLowLevel diff --git a/test/vanilla/version-tolerant/AcceptanceTests/asynctests/test_urlencoded.py b/test/vanilla/version-tolerant/AcceptanceTests/asynctests/test_urlencoded.py new file mode 100644 index 00000000000..e80bfc536e7 --- /dev/null +++ b/test/vanilla/version-tolerant/AcceptanceTests/asynctests/test_urlencoded.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddataversiontolerant.aio import BodyFormsDataURLEncoded + +@pytest.fixture +async def client(): + async with BodyFormsDataURLEncoded() as client: + yield client + +@pytest.mark.asyncio +async def test_update_pet_with_form(client): + await client.formdataurlencoded.update_pet_with_form( + 1, + { + "pet_type": "dog", + "pet_food": "meat", + "pet_age": 42, + "name": "Fido", + } + ) diff --git a/test/vanilla/version-tolerant/AcceptanceTests/test_urlencoded.py b/test/vanilla/version-tolerant/AcceptanceTests/test_urlencoded.py new file mode 100644 index 00000000000..fed9c247c85 --- /dev/null +++ b/test/vanilla/version-tolerant/AcceptanceTests/test_urlencoded.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from bodyformurlencodeddataversiontolerant import BodyFormsDataURLEncoded + +@pytest.fixture +def client(): + with BodyFormsDataURLEncoded() as client: + yield client + +def test_update_pet_with_form(client): + client.formdataurlencoded.update_pet_with_form( + 1, + { + "pet_type": "dog", + "pet_food": "meat", + "pet_age": 42, + "name": "Fido", + } + ) diff --git a/test/vanilla/version-tolerant/AcceptanceTests/test_zzz.py b/test/vanilla/version-tolerant/AcceptanceTests/test_zzz.py index de8c808278f..9aae2f61bc8 100644 --- a/test/vanilla/version-tolerant/AcceptanceTests/test_zzz.py +++ b/test/vanilla/version-tolerant/AcceptanceTests/test_zzz.py @@ -56,7 +56,6 @@ def test_ensure_coverage(self): 'putDateTimeMaxUtc7MS': 1, # Python doesn't support 7 digits ms datetime 'FormdataStreamUploadFile': 1, # Form data not supported yet 'StreamUploadFile': 1, # Form data not supported yet - "UpdatePetWithForm": 1, # autorest core change needed to do this hasn't been merged yet } for name in optional_report: if "Options" in name: @@ -64,6 +63,9 @@ def test_ensure_coverage(self): if "Multiapi" in name: # multiapi is in a separate test folder missing_features_or_bugs[name] = 1 + if "LLC" in name: + # llc is in a separate test folder + missing_features_or_bugs[name] = 1 print("Optional coverage:") self._print_report(optional_report, not_supported, missing_features_or_bugs) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/aio/operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/aio/operations/_operations.py index a455500e1fc..4104dfd844f 100644 --- a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/aio/operations/_operations.py +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/aio/operations/_operations.py @@ -75,13 +75,9 @@ async def upload_file(self, files: Dict[str, Any], **kwargs: Any) -> IO: content_type = kwargs.pop("content_type", None) # type: Optional[str] - data = None - # Construct form data - request = build_formdata_upload_file_request( content_type=content_type, files=files, - data=data, template_url=self.upload_file.metadata["url"], ) request.url = self._client.format_url(request.url) @@ -170,13 +166,9 @@ async def upload_files(self, files: Dict[str, Any], **kwargs: Any) -> IO: content_type = kwargs.pop("content_type", None) # type: Optional[str] - data = None - # Construct form data - request = build_formdata_upload_files_request( content_type=content_type, files=files, - data=data, template_url=self.upload_files.metadata["url"], ) request.url = self._client.format_url(request.url) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/operations/_operations.py index 670d3086196..4fe501126a8 100644 --- a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/operations/_operations.py +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/operations/_operations.py @@ -153,13 +153,9 @@ def upload_file( content_type = kwargs.pop("content_type", None) # type: Optional[str] - data = None - # Construct form data - request = build_formdata_upload_file_request( content_type=content_type, files=files, - data=data, template_url=self.upload_file.metadata["url"], ) request.url = self._client.format_url(request.url) @@ -258,13 +254,9 @@ def upload_files( content_type = kwargs.pop("content_type", None) # type: Optional[str] - data = None - # Construct form data - request = build_formdata_upload_files_request( content_type=content_type, files=files, - data=data, template_url=self.upload_files.metadata["url"], ) request.url = self._client.format_url(request.url) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/__init__.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/__init__.py new file mode 100644 index 00000000000..c4c48268a9b --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded +from ._version import VERSION + +__version__ = VERSION +__all__ = ["BodyFormsDataURLEncoded"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_body_forms_data_url_encoded.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..0aacbf6aebe --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_body_forms_data_url_encoded.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import BodyFormsDataURLEncodedConfiguration +from .operations import FormdataurlencodedOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.rest import HttpRequest, HttpResponse + + +class BodyFormsDataURLEncoded(object): + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdataurlencoded: FormdataurlencodedOperations operations + :vartype formdataurlencoded: + bodyformurlencodeddataversiontolerant.operations.FormdataurlencodedOperations + :keyword endpoint: Service URL. Default value is 'http://localhost:3000'. + :paramtype endpoint: str + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + endpoint = kwargs.pop("endpoint", "http://localhost:3000") # type: str + + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = PipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.formdataurlencoded = FormdataurlencodedOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> BodyFormsDataURLEncoded + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_configuration.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_configuration.py new file mode 100644 index 00000000000..1630989c8c5 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_configuration.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_vendor.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_vendor.py new file mode 100644 index 00000000000..54f238858ed --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_vendor.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_version.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/__init__.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/__init__.py new file mode 100644 index 00000000000..d29143c0791 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/__init__.py @@ -0,0 +1,11 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._body_forms_data_url_encoded import BodyFormsDataURLEncoded + +__all__ = ["BodyFormsDataURLEncoded"] diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_body_forms_data_url_encoded.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_body_forms_data_url_encoded.py new file mode 100644 index 00000000000..368d8a9dab1 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_body_forms_data_url_encoded.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import BodyFormsDataURLEncodedConfiguration +from .operations import FormdataurlencodedOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + +class BodyFormsDataURLEncoded: + """Test Infrastructure for AutoRest Swagger BAT. + + :ivar formdataurlencoded: FormdataurlencodedOperations operations + :vartype formdataurlencoded: + bodyformurlencodeddataversiontolerant.aio.operations.FormdataurlencodedOperations + :keyword endpoint: Service URL. Default value is 'http://localhost:3000'. + :paramtype endpoint: str + """ + + def __init__(self, *, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + self._config = BodyFormsDataURLEncodedConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.formdataurlencoded = FormdataurlencodedOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "BodyFormsDataURLEncoded": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_configuration.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_configuration.py new file mode 100644 index 00000000000..71cd7fc41ca --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class BodyFormsDataURLEncodedConfiguration(Configuration): + """Configuration for BodyFormsDataURLEncoded. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(BodyFormsDataURLEncodedConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "bodyformsdataurlencoded/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/__init__.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/__init__.py new file mode 100644 index 00000000000..0e8053ce76c --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import FormdataurlencodedOperations + +__all__ = [ + "FormdataurlencodedOperations", +] diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/_operations.py new file mode 100644 index 00000000000..35ed23d17b5 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/aio/operations/_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ...operations._operations import build_formdataurlencoded_update_pet_with_form_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FormdataurlencodedOperations: + """FormdataurlencodedOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def update_pet_with_form(self, pet_id: int, data: Dict[str, Any], **kwargs: Any) -> None: + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :param data: Form-encoded input for data. See the template in our example to find the input + shape. + :type data: dict[str, any] + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # form-encoded input template you can fill out and use as your `data` input. + data = { + name: "str", # Optional. Updated name of the pet. + pet_age: 0, # How many years is it old?. + pet_food: "str", # Can take a value of meat, or fish, or plant. Possible values are: "meat", "fish", and "plant". + pet_type: "str", # Can take a value of dog, or cat, or fish. Possible values are: "dog", "cat", and "fish". + status: "str" # Optional. Updated status of the pet. + } + """ + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + content_type = kwargs.pop("content_type", "application/x-www-form-urlencoded") # type: Optional[str] + + request = build_formdataurlencoded_update_pet_with_form_request( + pet_id=pet_id, + content_type=content_type, + data=data, + template_url=self.update_pet_with_form.metadata["url"], + ) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 405]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update_pet_with_form.metadata = {"url": "/formsdataurlencoded/pet/add/{petId}"} # type: ignore diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/__init__.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/__init__.py new file mode 100644 index 00000000000..0e8053ce76c --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import FormdataurlencodedOperations + +__all__ = [ + "FormdataurlencodedOperations", +] diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/_operations.py new file mode 100644 index 00000000000..bf9742be004 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/operations/_operations.py @@ -0,0 +1,140 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer + +from .._vendor import _format_url_section + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_formdataurlencoded_update_pet_with_form_request( + pet_id, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + # Construct URL + url = kwargs.pop("template_url", '/formsdataurlencoded/pet/add/{petId}') + path_format_arguments = { + "petId": _SERIALIZER.url("pet_id", pet_id, 'int'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class FormdataurlencodedOperations(object): + """FormdataurlencodedOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def update_pet_with_form( + self, + pet_id, # type: int + data, # type: Dict[str, Any] + **kwargs # type: Any + ): + # type: (...) -> None + """Updates a pet in the store with form data. + + Updates a pet in the store with form data. + + :param pet_id: ID of pet that needs to be updated. + :type pet_id: int + :param data: Form-encoded input for data. See the template in our example to find the input + shape. + :type data: dict[str, any] + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # form-encoded input template you can fill out and use as your `data` input. + data = { + name: "str", # Optional. Updated name of the pet. + pet_age: 0, # How many years is it old?. + pet_food: "str", # Can take a value of meat, or fish, or plant. Possible values are: "meat", "fish", and "plant". + pet_type: "str", # Can take a value of dog, or cat, or fish. Possible values are: "dog", "cat", and "fish". + status: "str" # Optional. Updated status of the pet. + } + """ + cls = kwargs.pop("cls", None) # type: ClsType[None] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + + content_type = kwargs.pop("content_type", "application/x-www-form-urlencoded") # type: Optional[str] + + request = build_formdataurlencoded_update_pet_with_form_request( + pet_id=pet_id, + content_type=content_type, + data=data, + template_url=self.update_pet_with_form.metadata["url"], + ) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 405]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update_pet_with_form.metadata = {"url": "/formsdataurlencoded/pet/add/{petId}"} # type: ignore diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/py.typed b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/setup.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/setup.py new file mode 100644 index 00000000000..25974680ef5 --- /dev/null +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/setup.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "bodyformsdataurlencoded" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.19.0"] + +setup( + name=NAME, + version=VERSION, + description="BodyFormsDataURLEncoded", + author_email="", + url="", + keywords=["Swagger", "BodyFormsDataURLEncoded"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest Swagger BAT. + """, +) diff --git a/test/vanilla/version-tolerant/coverage/report-optional.json b/test/vanilla/version-tolerant/coverage/report-optional.json index a94659e10df..e43f4558792 100644 --- a/test/vanilla/version-tolerant/coverage/report-optional.json +++ b/test/vanilla/version-tolerant/coverage/report-optional.json @@ -1,6 +1,6 @@ { "StreamUploadFile": 10, - "UpdatePetWithForm": 0, + "UpdatePetWithForm": 2, "getDecimalInvalid": 2, "getDecimalBig": 2, "getDecimalSmall": 2, diff --git a/test/vanilla/version-tolerant/requirements.txt b/test/vanilla/version-tolerant/requirements.txt index 7b54cc29c85..fce6766d733 100644 --- a/test/vanilla/version-tolerant/requirements.txt +++ b/test/vanilla/version-tolerant/requirements.txt @@ -21,6 +21,7 @@ azure-core==1.19.0 -e ./Expected/AcceptanceTests/BodyDurationVersionTolerant -e ./Expected/AcceptanceTests/BodyFileVersionTolerant -e ./Expected/AcceptanceTests/BodyFormDataVersionTolerant +-e ./Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant -e ./Expected/AcceptanceTests/BodyIntegerVersionTolerant -e ./Expected/AcceptanceTests/BodyNumberVersionTolerant -e ./Expected/AcceptanceTests/BodyStringVersionTolerant